Structure of ODBC

Source: Internet
Author: User
Tags driver manager odbc

If an application calls an ODBC API function, the ODBC Administrator or driver Manager passes the command to the appropriate driver. After translation, the driver passes the command to a particular backend database server, using the language or code it understands. Any result or result set returned through ODBC will be passed along in the opposite direction. The structure of ODBC is shown in the figure:


Diagram: Structure of ODBC

For Visual Basic applications, the driver and Driver Manager (Driver Manage) is a whole when processing function calls. The application uses the ODBC API to accomplish the following tasks:
(1) Request to establish a connection with the data source to create a session;
(2) Making a SQL request to the data source;
(3) defines a buffer and data format for storing SQL request results;
(4) Extracting the results of the SQL request;
(5) Handling all kinds of errors;
(6) Report the result to the user;
(7) The transaction commits or the transaction is revoked;
(8) Interrupt the connection to the data source.
In the above structure, the driver Manager (Driver Manager) is a DLL that is provided by Microsoft and is a dynamic connection with a portal function library, and the basic task of the driver manager is to load the driver. In addition, you have the following features:
(1) According to the Odbc.ini file, the data source name is mapped to the corresponding driver;
(2) Processing of several ODBC initialization functions;
(3) The legalization test of the parameters.
The SQL Server ODBC driver in the structure diagram is a DLL that completes the ODBC function call and talks to the data source. The driver manager loads the driver when an application calls Sqldriverconnection. Depending on the requirements of the program, the driver can accomplish the following tasks:
(1) Establishing a connection with the data source;
(2) Submitting the request to the data source;
(3) To complete the conversion of data format according to the needs of the application;
(4) Return the result to the application;
(5) Application and control of Cursors (Cursor);
(6) completes the transaction initialization according to the need of the data source.
These features are transparent to the application.
The physical data source in the structure diagram is a complex of DBMS, operating system and network platform.
As elsewhere in Windows, ODBC uses the appropriate handle to handle objects. You must obtain this handle from ODBC or windows before you can really do something. ODBC provides four handles: environment, connection, statement, and descriptor handles, and must request an environment handle before connecting to the data source. The purpose of the connection handle is to assign the resource to the actual data source connection. The application must first request a connection handle before connecting to the data source. Each connection handle is connected to only one environment handle, and an environment handle can be connected to multiple connection handles; The statement handle is used to manage the actual request to the system, it must be associated with a connection, and the connection must be associated with the environment. The application must request a statement handle before submitting the SQL request. Each statement handle is connected to only one connection handle, and a connection handle can be connected to multiple statement handles; Description Fu provides special descriptive information, such as data column information for the result set, or dynamic parameters of the SQL statement, and so on. The following illustration shows the relationship between the environment handle, the connection handle, and the statement handle.

Each type of SQL data corresponds to a Visual Basic data type. By default, the driver assumes that the data type of the column or parameter in the SQL statement corresponds to the Visual Basic data type on which the connection is attached. If the Visual Basic data type does not use the default data type, the application can specify another data type with the parameter Fctype in the function SQLBindCol, SQLGetData, and SQLBindParameter. The driver converts the data to the specified data type before returning data from the data source. Similarly, the driver converts the specified Visual Basic data type to a SQL data type before it is passed to the data source.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.