Introduction to ODBC in MFC
MFC
The ODBC class encapsulates complex ODBC APIs and provides simplified calling interfaces, which greatly facilitates the development of database applications. Programmers can perform most database operations without having to know the detailed odbc api and SQL.
MFC
ODBC categories include:
Cdatabase
Class: The main function is to establish a connection with the data source.
Crecordset
Class: This class indicates a set of records (record set) selected from the data source. The program can select a table in the data source as a record set, or obtain a record set by querying the table, you can also merge columns from multiple tables in the same data source to one record set. this type allows you to scroll, modify, add, and delete records in a record set.
Crecordview
Class: A form view is directly connected to a record set, and data is transmitted between the control of the record set and form view using the dialog box data exchange mechanism (DDX. This class supports browsing and updating records, and the associated record set is automatically closed when you cancel the operation.
Cfieldexchange
Class: supports field data exchange (DFX), that is, the data exchange between the members of the record set field data and the fields of the corresponding database table. This type of function is similar to the dialog box data exchange function of the cdataexchange class.
Cdbexception
Class: indicates the exceptions of the ODBC class.
To sum up,
Cdatabase is used for a database to connect to the data source. crecordset is used for record set operations in the data source. crecordview is used for the interface, and cfieldexchange is used for data exchange between crecordset and the data source.
Exploitation
Appwizard and classwizard. You can easily create database applications, but this does not mean that you can know nothing about the ODBC class of MFC. readers should read the content in the following sections to lay a solid foundation for the examples.