VB 4.0 call to SQL Server - no ODBC

Posted on 1998-06-30
Last Modified: 2010-05-03
I am in the process of completing a VB 4.0 application which needs read-only access to a database.  This database was originally set up on Sybase, and I accessed it using ODBC (that part worked!).  However, it has since migrated to an SQL server, and I've been instructed to avoid using ODBC for configuration reasons.

My problem is in accessing the database now that it's on SQL.  Below I've included both the 'old' Sybase call, as well as my attempt at the new call to the SQL server:

'Below are the two statements that we'd used previously to connect to the Sybase database:
'connect_string = "ODBC;DSN=DEPT;DATABASE=EMPLOY;"
'Set db = OpenDatabase("DEPT", False, False, connect_string)

'Below is what I've been trying now that the database has been migrated to SQL:
connect_string = "DSN=DEPX;DATABASE=EMPLOY;"
Set db = OpenDatabase("DEPX", False, False, connect_string)

(DEPT is the Sybase server, DEPX is the SQL server, and EMPLOY is the database name on both servers)

I can access the database using ISQL outside the application, but whenever I try from within the application, it dies with this error:  
[ODBC MS SQL Server 6 driver][MS SQL Server 6] Unable to connect: SQL Server is unavailable or does nto exist.  Access denied.

Thanks in advance for any help you can give this frustrated newbie!
Question by:BooH
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

Expert Comment

ID: 1464632
ODBC is the native access mode for SQL Server.  Your SQL Server drivers are set up using the 32 bit ODBC driver manager software, and your DSN (DEPX) should be set up via that route.  It will specify the database at configuration time.

There is really no problem using ODBC to get to SQL server, depending on your access method.  You do need the updates to 4.0 release to get repaired and working versions of the 32bit controls, and RDO 1.0 if you are using the enterprise version.  Note that you can downlaod and use RDO 2.0 from the VB 5.0 version in VB 4.0 as well, and it fixes even more of the massive memory leak problems and quirks that were in the original 1.0 release of RDO.  If you are not using the Enterprise version of VB, best youy get it if doing much SQL Server work.  Using DAO  presents too many problems and limitatins to the serious user.

Read "Hitchiker's Guide to Visula Basic and SQL server" by W.R. Vaughn, Microsoft PRess for a good resource on these methods.

Author Comment

ID: 1464633
Forgive any stupidity that is about to be shown....

I'm not sure what the response means.  Are there additional .DLLs I need to incorporate to 'fix' issues with 4.0?  Can I still use ODBC calls without having to install it on each PC when this is rolled out?

Sorry, but I'm lost!

Expert Comment

ID: 1464634
here is an example i used to connect with SQL server using SQL ODBC.

Set MyDatabase = MyWorkspace.OpenDatabase("", 0, 0, "DSN=LOAN;UID=LoanUser;PWD=LOAN;DATABASE=LOAN")

I think you have missed the user id (UID) and the password (PWD)

and make sure you have already added the user id in the SQL Server.

I hope this gives you some hints.

Author Comment

ID: 1464635
Unfortunately, I need a way to avoid using ODBC, but thanks for the suggestion.

Accepted Solution

dabellei earned 100 total points
ID: 1464636
If you need to avoid ODBC then you should use vbsql.vbx this was a release for VB 3 but still work on VB 4 and VB 5.  I've writen an application in Vb using this vbx performance was a lot better than with ODBC even over a modem connection at 28,800.

You need to know SQL since there no documentation with this VBX.  You can get it on microsoft site somewhere or i can email you this vbx if you want to

You may have to reddo part of your code to since the call are different from ODBC.


Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month8 days, 23 hours left to enroll

617 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