• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

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

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
BooH
Asked:
BooH
1 Solution
 
wizard2072098Commented:
After executing the SqlOpenConnection command, execute the SqlUse command to change the database context, as such:

Results% = SqlUse(SqlConn&, "pubs")

That code changes the database context from the master to the pubs database.

Then it's just a matter of executing SqlCmd() and SqlExec() commands, along with SqlNextRow(), etc. to get the data out of the recordset.
0
 
telebasicsCommented:
Where the *&^ do those commands come from? my VB doesn;t know them and i can't find a control that does. Please tell me
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now