Databases Reference
In-Depth Information
In addition, if SQLDriverConnect receives an empty connection string, the Driver
Manager displays a dialog box prompting the user for the correct DSN.
C.5 Getting ODBC Driver Help
You may be able to get some limited help for an ODBC driver by starting the DSN
creation process through the ODBC Administrator and then clicking the Help button once
a driver-specific dialog box appears. This brings up the ODBC Microsoft Desktop
Database Drivers Help file. However, this information is at best sketchy and often
misleading. For instance, under the topic Section C.4.6, the help file says that a
connection string includes the following keywords:
DSN
Name of the data source
DBQ
Name of the directory
DRIVERID
An integer ID for the driver
FIL
File type
However, as you will see in the upcoming examples, the DBQ value is the name of the
directory for the Microsoft Text Driver, but not the name of the actual workbook for the
Microsoft Excel Driver! The help file also does not give any indication as to when or
whether these keywords are always required. Nevertheless, the information contained in
the help file can be very useful.
C.6 Getting ODBC Information Using Visual Basic
It is clear that in order to use ODBC effectively, the programmer may need to know what
drivers and data sources exist on a particular computer. This information is accessible
through a few ODBC API calls.
The following code includes a procedure called ListODBCSources , which prints (to the
Immediate window) a list of all data sources on a system, and ListODBCDrivers , which
prints a list of ODBC drivers on the system. This code can be placed in an Access code
module:
Const SQL_NULL_HANDLE = 0
 
 
Search WWH ::




Custom Search