Creating an ODBC Application

ODBC architecture has four components that perform the following functions.

Component Function
Application Calls ODBC functions to communicate with an ODBC data source, submits SQL statements, and processes result sets.
Driver Manager Manages communication between an application and all ODBC drivers used by the application.
Driver Processes all ODBC function calls from the application, connects to a data source, passes SQL statements from the application to the data source, and returns results to the application. If necessary, the driver translates ODBC SQL from the application to native SQL used by the data source.
Data source Contains all information a driver needs to access a specific instance of data in a DBMS.

An application that uses the ODBC interface to communicate with Microsoft® SQL Server™ performs the following tasks:

A more complex application written for the SQL Server ODBC driver might also perform the following tasks:

To make ODBC function calls, a C or C++ application must include the Sql.h, Sqlext.h, and Sqltypes.h header files. To make calls to the ODBC installer API functions, an application must include the Odbcinst.h header file. A Unicode ODBC application must include the Sqlucode.h header file. ODBC applications must be linked with the Odbc32.lib file. ODBC applications that call the ODBC installer API functions must be linked with the Odbccp32.lib file. By default, SQL Server Setup 7.0 installs these header files into the C:\Mssql7\Devtools\Include directory and the library files into C:\Mssql7\Devtools\Lib when the SQL Server development tools are installed. The latest versions of these files can be downloaded with the latest Microsoft Data Access SDK from http://www.microsoft.com/data.

Many ODBC drivers, including the SQL Server ODBC driver, offer driver-specific ODBC extensions. To take advantage of SQL Server ODBC driver-specific extensions, an application should include the Odbcss.h header file. This header file contains:

Any C or C++ ODBC application that uses the bulk copy feature of the SQL Server version 7.0 ODBC driver must be linked with the Odbcbcp.lib file. Applications calling the distributed query metadata API functions must also be linked with Odbcbcp.lib. The Odbcss.h and Odbcbcp.lib files are distributed as part of the SQL Server developer’s tools. The SQL Server Include and Lib directories should be in the compiler’s INCLUDE and LIB paths. If you have downloaded a version of the Microsoft Data Access SDK whose dates are later than the dates for SQL Server version 7.0, place the MSDA directories before the SQL Server 7.0 directories; for example:

LIB=c:\msdasdk\odbc\lib;c:\mssql7\DevTools\lib;c:\msdev\lib;c:\msdev\mfc\lib

INCLUDE=c:\msdasdk\odbc\include;c:\mssql7\DevTools\include;c:\msdev\include;

c:\msdev\mfc\include

  

One design decision made early in the process of building an application is whether the application needs to have multiple ODBC calls outstanding at the same time. There are two methods for supporting multiple concurrent ODBC calls:

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.