ODBC Data Sources

When using the DataFlex ODBC Driver you will have to setup an ODBC data source to connect to. This section introduces ODBC data sources.

There are two types of Data Sources, machine- and file Data Sources. Both types contain similar information, they differ in the way the information is stored. Because of these differences, they are used in a somewhat different manner.

Machine Data Sources are stored on the client system. Associated with the Data Source is all the information the ODBC Manager and database driver need to connect to the specified database. There are two Data Source subtypes, User- and System Data Sources. One specific user of the machine can use a User Data Sources; all users that use the machine where the Data Source is defined can use a System Data Source.

File Data Sources are stored in a file with extension .dsn (in ASCII format). The file Data Source stores all the information the ODBC Manager and database driver need to connect to the specified database. The file can be manipulated like any other text file.

Creating a Data Source

Data Sources are created with a program called the ODBC Administrator. The ODBC Administrator can be started from the Control Panel or from Database Builder. Some database environments add a shortcut to the ODBC Administrator to the start menu options.

 

 

When adding a Data Source the ODBC Administrator presents a list of all available drivers. The user chooses one driver and the Administrator passes control to the driver set up logic so it can obtain all required information. The information required to set up a Data Source for a driver is driver (and backend) specific. See below for a sample of a driver set up panel. Depending on the Data Source type the information is stored in the machines registry or a disk file.

 

 

Information of a particular Data Source is stored in the following way:


DSN Type

Information Location

 

User

User data sources are stored in the registry at HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.INI under this key a subkey for every User Data Source can be found.

User Data Sources are typically used in an environment where there is only one user or as a test for ODBC connectivity.

System

System Data Sources are stored in the registry at HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI under this key a subkey for every System Data Source can be found.

System Data Sources are typically used when there is a need to access data from one machine. This usually is a server type process like the DataFlex Web Application Server.

File

File Data Sources are stored in disk files. For specifics on the contents of the file data source, see your ODBC driver’s documentation.

File Data Sources can be shared among all users that have access to the disk file.

 

When an application needs to access the data defined in a Data Source, it calls the ODBC Manager and passes the name of the data source. The ODBC Manager identifies the driver to use, loads it and passes the Data Source name. The driver uses the Data Source name to connect to the Data Source. Connecting to a Data Source may involve prompting the user for login information.

 

See Also

Connectivity Concepts