Solved

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

Posted on 1998-07-22
8
595 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
 

Author Comment

by:BooH
ID: 1089166
And thank you so much!!!!
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
grouping logic 6 46
Get Duration of last Status Update 4 29
recover sqlserver db 8 7
Help Parsing a String with SQL Syntax 23 0
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…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

943 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

6 Experts available now in Live!

Get 1:1 Help Now