ODBC foundation

zhaozj2021-02-17  59

ODBC foundation

This is the first tutorial using Win32ASM for database programming series. In today's IT, database programming is getting more and more important, so we can't ignore it. But now there are many databases in use. If we learn from the database assembly language programming language programming language programming, it is probably called "eternal".

Fortunately, a technology of Microsoft makes us get rid of this big trouble. It is called ODBC, an abbreviation of open database interconnectivity, which is a family API, similar to the Windows API. It mainly deals with the database. That is to say, using the ODBC API, you can deal with a lot of different databases and a lot of different databases.

How is ODBC work? What is its structural style? Before using ODBC, you should have a clear understanding of its structure. ODBC has four components:

Application (Application, Your Program) ODBC Manager (ODBC Manager) ODBC Driver (ODBC DRIVERS) Data Source (Data Sources, Database)

The core of these four components is an ODBC Manager. You can imagine it into your supervision. You tell you what you want him, then it conveys your request to its worker (ODBC driver) and completes work. If the worker has anything to tell you, it will talk to the supervisor (ODBC Manager), conveyed by the supervision. Workers understand what they should do, so they will work for you very well.

Through this model, we don't communicate directly with the database driver. You just need to tell the database manager what you want to do. The use of the appropriate ODBC driver to achieve your purpose is the ODBC manager. Each ODBC driver is sufficient to understand the database it. Each part of each part is greatly simplified.

Your program <----> ODBC Manager <----> ODBC Driver <----> Database

The ODBC Manager is provided by Microsoft. Look at your control panel. If you correctly install ODBC, you will find the ODBC data source (32-bit) project. As for the ODBC driver, Microsoft provides several kinds of their products. And you can always get new ODBC drivers from database providers. As long as you simply install a new ODBC driver, your machine can use the new database you have before.

ODBC APIS is very simple, but you need to know some knowledge about SQL and databases. For example, a field (Primary Key), record (COLUMN), Row (ROW), and the like. I have to suppose some basic knowledge of the database theory, so I can discuss the details of the ODBC programming in Win32. As you can see, the ODBC Manager tries to hide the details of your implementation in your program. This means that it must provide some basic interfaces to communicate with your program and ODBC drivers. Since the ODBC driver has differences in certain performance, there must be a method to make our program to know if an ODBC driver supports a certain feature. ODBC defines a three-layer service interface called Interface Conformance Levels. The third layer is the core layer. Any ODBC driver must realize all of the characteristics in the core layer table like the first layer and the second layer implementation. From the perspective of our program, ODBC APIs are split into such a three-layer. If a function is marked as the core, you can use it with confidence and don't worry if it is supported by the ODBC driver you are using. If it is a first layer or a second layer, you have to confirm whether the ODBC driver supports and then use. You can get detailed information on ODBC APIs via MSDN.

You should understand some ODBC nouns before writing code.

Environment. Like literally, it is a global text to access data. If you are familiar with DAO, you can imagine it as a Workspace. It contains information applied to all ODBC session, such as a SESSION Connections handle. You must get this handle from the environment before using ODBC. Connection. Specify the ODBC driver and data source (database). You can simultaneously connect different database statements (statement) in the same environment. ODBC uses SQL as its own language. Therefore, as long as the simple think statement is that you want the SQL command that ODBC executes. Here are the general steps programming using ODBC:

Connect the data source to create and execute one or more SQL statement check results record (if any) disconnected

In the next tutorial, let's learn how to implement these steps.

转载请注明原文地址:https://www.9cbs.com/read-30102.html

New Post(0)