Solved

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

Posted on 1998-07-22
2
194 Views
Last Modified: 2012-05-05
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
2 Comments
 
LVL 1

Accepted Solution

by:
wizard2072098 earned 70 total points
ID: 1466443
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
 
LVL 2

Expert Comment

by:telebasics
ID: 4878359
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now