To use an ODBC data source in your application, the ODBC configuration must include:
An entry for the data source in ODBC.INI with instructions on how to start the database
An entry for the DBMS driver in ODBCINST.INI
To allow the user to connect to a particular data source, your installation program must provide a definition for that data source in the ODBC.INI key in the registry on the computer that accesses the data source, in HKEY_CURRENT_USER for a user DSN or in HKEY_LOCAL_MACHINE for a system DSN. The data source definition specifies the name and location of the database driver as well as the command required to start the database engine. The data source in the ODBC Data Sources key must also be listed in ODBC.INI.
The following shows typical registry entries for a data source
called MyApp DB that uses SQL Anywhere. Registry
keys are enclosed in square brackets and are followed by string
values for that key in the format "Name"="Value"
:
[HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.INI\MyApp DB] "Driver"="C:\Program Files\SQL Anywhere 11\ Bin32\dbodbc11.dll" "Start"="C:\Program Files\SQL Anywhere 11\Bin32\ dbeng11.exe" "UID"="dba" "PWD"="sql" "Description"="Database for my application" "DatabaseFile"="C:\Program Files\myapps\myapp.db" "AutoStop"="Yes" [HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.INI\ ODBC Data Sources] "MyApp DB"="SQL Anywhere 11.0"
You might use one of the following ways to make the modifications to ODBC.INI:
Use Microsoft’s ODBC Administrator control panel, if the control panel is available on the user’s system.
Use a software distribution application that includes ODBC configuration instructions to do your installation.
For more information about the contents of the registry entries for ODBC drivers and data sources, see Connecting to Your Database.
Your installation program needs to make two types of entry in the ODBCINST.INI key in HKEY_LOCAL_MACHINE\SOFTWARE\ODBC for each driver that your deployed application uses:
Add a string value with the name of the driver and the data value "Installed" to the ODBC DRIVERS key in ODBCINST.INI
Add a new key for each driver to the ODBCINST.INI key with string values for Driver and Setup
Some drivers require additional string values in ODBCINST.INI.
If the ODBC database driver files are not located in a directory on the system path, you also need to add their location to the App Paths key for the executable file in the registry.
If you are using ODBC drivers obtained from a vendor, you can use the driver’s setup program to install the driver and create registry entries.
The following shows typical registry entries for SQL Anywhere.
Registry keys are enclosed in square brackets and are followed by
string values for that key in the format "Name"="Value"
:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\ CurrentVersion\App Paths\myapp.exe] "Default"="C:\Program Files\myapps\MYAPP.EXE" "Path"="Program Files\sybase\shared\PowerBuilder; C:\Program Files\SQL Anywhere 11\Bin32\;" [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ ODBC Drivers] "SQL Anywhere 11"="Installed" [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ SQL Anywhere 11] "Driver"="C:\Program Files\SQL Anywhere 11\ Bin32\dbodbc11.dll" "Setup"="C:\Program Files\SQL Anywhere 11\ win32\dbodbc11.dll"
For more information about the contents of the registry entries for ODBC drivers and data sources, see Connecting to Your Database.