Export (0) Print
Expand All

Programming ODBC SQL Server Applications

SQL Server 2000

ODBC is a standard definition of an application programming interface (API) used to access data in relational or indexed sequential access method (ISAM) databases. Microsoft® SQL Server™ supports ODBC as one of the native APIs for writing C, C++, and Microsoft Visual Basic® applications that communicate with SQL Server. SQL Server Setup installs an ODBC driver for use with SQL Server when it installs the SQL Server client utilities.

ODBC defines a call-level interface, or CLI. A CLI is defined as a set of function calls and their associated parameters. A CLI definition uses a native programming language to call functions; therefore a CLI requires no extensions to the underlying programming language. This contrasts with an embedded API, such as Embedded SQL, where the API is defined as an extension of the source code for a programming language, and applications using the API must be precompiled in a separate step.

ODBC aligns with the following specification and standard for relational SQL database CLI definitions:

  • The X/Open CAE specification Data Management: SQL Call-Level Interface (CLI)

  • ISO/IEC 9075-3:1995 (E) Call-Level Interface (SQL/CLI)

While C, C++, and Visual Basic applications can be written to call ODBC directly, Microsoft also provides several APIs that map over ODBC. These APIs are simpler than ODBC itself, or offer improved integration with their respective programming languages:

  • Microsoft Visual Basic Remote Data Objects (RDO)

  • Microsoft Visual Basic Data Access Objects (DAO)

  • Microsoft Visual C++® development system MFC database classes

  • Microsoft Visual C++ development system DAO classes

While Visual Basic applications can be written directly to the ODBC API, they are usually written to either the RDO or DAO APIs.

SQL Server programs that are written using the ODBC API communicate with SQL Server through C function calls. The SQL Server-specific versions of the ODBC functions are implemented in a SQL Server ODBC driver. The driver passes SQL statements to SQL Server and returns the results of the statements to the application. ODBC applications are also interoperable with drivers for heterogeneous data sources.

The SQL Server ODBC driver complies with the Microsoft Win32® ODBC 3.51 specification. The ODBC function calls in this document use ODBC 3.51 syntax. The driver supports applications written with the ODBC 2.5 or earlier versions of the ODBC functions in the manner defined in the ODBC 3.51 specification.

ODBC enables a database to become an integral part of an application. SQL statements can be incorporated into the application, allowing the application to retrieve and update values from a database. Values from the database can be placed in program variables for manipulation by the application. Conversely, values in program variables can be written to the database.

ODBC enables applications to access a variety of data sources, including a wide range of relational databases and local ISAM data. ODBC supports applications in the Microsoft Windows® 2000, Microsoft Windows 98, Microsoft Windows 95, and Microsoft Windows NT® 4.0 operating environments.

Tools for developing C and C++ applications using the ODBC API are available in the Microsoft ODBC Software Development Kit (SDK). The ODBC SDK is part of the Microsoft Developer Network (MSDN®) Professional subscription. The ODBC SDK can also be downloaded from the Microsoft Web site, and is available in the Microsoft ODBC 3.0 Software Development Kit and Programmer's Reference available from Microsoft Press®. The ODBC driver for SQL Server is included with SQL Server. Visual Basic includes all the components necessary to build applications using the RDO and DAO APIs. Visual C++ includes all the components necessary to build C and C++ applications using the DAO and MFC database classes.

Show:
© 2014 Microsoft