Database classes designed to seamlessly move between ODBC and the OLE DB interface without code changes. Designed with a generic database interface and a class factory pattern to remove traces of any technology specific class implementation.
The classes expose storage information in the traditional Recordset and Command object types.
The ODBC classes are being tested with various database vendors, while
the OLE DB classes are still in development. The OLE DB wrappers require
the ATL atlbase.h
file to be included.
You are probably asking why you would not just use the
ATL OLE DB Client (Consumer) classes?
After all, you can access ODBC through the
"OLE DB Provider for ODBC"?
I don't really have a good answer to that one, except perhaps for
the need for good performance with both ODBC and OLE DB in the same app.
The sample also includes classes for CSV files (Comma Separated Files; no SQL) and for the SQLite database (version 2 and 3).
Code sample
The following sample requires a predefined DSN for the good old Northwind sample database. COdbcSystem System;
System.Initialize();
COdbcDatabase Db(&System);
Db.Open(NULL, "Northwind", "", "");
COdbcRecordset Rec(&Db);
Rec.Open("SELECT ProductID,ProductName FROM Products");
while( !Rec.IsEOF() ) {
long lID;
char szName[128];
Rec.GetField(0, lID);
Rec.GetField(1, szName, 128);
Rec.MoveNext();
}
Rec.Close();
Db.Close();
System.Terminate();
Source Code Dependencies
Microsoft Visual C++ 6.0Download Files
![]() | Source Code (58 Kb) |