Solved

SQL 6.5 & VB - No ODBC - How to set database?

Posted on 1998-07-22
8
598 Views
Last Modified: 2008-02-01
I'm creating a VB 4.0 application to access data on an SQL server 6.5 database.  I'm not using ODBC, but an .ini file instead.  My last stumbling block (I hope!) is how to set the database parameter so that I can create a recordset with the results of my query.

Below is what PREVIOUSLY set the database for me (when the data was on Sybase, and we used ODBC):
    connect_string = "ODBC;DSN=APPLE;DATABASE=SEED1;"
    Set db = OpenDatabase("APPLE", False, False, connect_string)

The following code is what NOW sets the connection to the database, but it doesn't set the actual database object:
    SqlConn& = SqlOpenConnection(ServerName$, User$, Pwd$, "", "")


I know I'm connecting to the server and database successfully, but just can't seem to set the database parameter.  This is killing me because when I go to run the query against the database, I can't create the recordset without the database object as a reference (see below):
     Set gSrchSet = db.OpenRecordset(gSrchStr, dbReadOnly)

It doesn't know what 'db' is.  

Please help me!  I've been going crazy on this for weeks!  Huge appreciation to anyone who can help!  Thanks so much!
0
Comment
Question by:BooH
8 Comments
 

Author Comment

by:BooH
ID: 1089163
Edited text of question
0
 

Expert Comment

by:orodriguez
ID: 1089164
send me your e-mail i will send you zip files samples  how to connect to an sql server
and retrieve data fromt using odbc an not using odbc


0
 

Author Comment

by:BooH
ID: 1089165
traci.hueskes@eds.com
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:BooH
ID: 1089166
And thank you so much!!!!
0
 

Expert Comment

by:coggie
ID: 1089167
Hi BooH,

Set db = CurrentDB() ?

Coggie
0
 

Author Comment

by:BooH
ID: 1089168
I tried the 'set db = currentdb()', but it isn't a defined function.  Thanks, though!
0
 
LVL 3

Expert Comment

by:altena
ID: 1089169
truly amazing:
"using odbc an not using odbc"

Unless you have a VERY good excuse for trying to stunt like
this, please reconsider your design. For your own and your
customer's sake.
0
 

Accepted Solution

by:
kilobugs earned 100 total points
ID: 1089170
1st of all, we have to straight out something right here. You are using VBSQL library which is no longer supported in VB5. So be careful if you want to carry you code over to VB5. Okay, back to your question! I think you are pretty much mixed up the use of "OpenRecordset" with VBSQL library. Basically, "OpenRecordset" is for DAO and RDO. I think if you successfully establish a connection with your SQL Server, then you have to use "SQLCmd" pass the query from you application to your SQL Server. Then you have to use "SQLExec" to execute your SQL statement. And then, you have to use "SQLResults" to retrieve your resultsets!
Your question is pretty tricky ... ! Try looking up SQLCmd(SQLConn), SQLExec(SQLConn), and SQLResults(SQLConn) from your VB4 help! I think most of the people in here are either using DAO or RDO and that you have to set up a DSN connection or a DSN-less connection. Try DAO or RDO, I think it is a little bit better than VBSQL library.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Count with a subquery showing details 10 44
export sql results to csv 6 36
SSRS 2013 - Creating a summarized report 19 35
Simple SQL query from two tables 13 54
When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question