?
Solved

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

Posted on 1998-07-22
8
Medium Priority
?
606 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

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 200 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Suggested Courses

801 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