C++/MFC SQLite Access classes
These class library provided with full source code is designed to simplify access to the SQLite databases from your VisualC++/MFC programs. The library consists of the two classese: CSQLiteDatabase and CSQLiteRecordset.
CSQLiteDatabase class
The CSQLiteDatabase class implements access to the database. The main class methods are:
- BOOL Connect(LPCTSTR szDatabase, LPCTSTR szLogin, LPCTSTR szPassword, CString &sError)
Connects to the database. The first parameters addresses the database disk file to open, 2nd and 3rd parameters are not used and the last OUT-parameters returns the description of the error occured
- BOOL Disconnect()
Disconnects from the previously connected database. No error information is given in the case of failure
- BOOL Query(LPCTSTR szStatement, CString &sError, CAbstractRecordset **ppRecordset)
Executes a query that does return a recordset. The 3rd parameter receives a pointer to the recordset created in the case of success.
- BOOL Query(LPCTSTR szStatement, CString &sError)
Executes a query that does not return a recordset against a database and returns the error description if necessary.
CSQLiteRecordset class
The CSQLiteRecordset class implements a recordset that is returned by the call to CSQLiteDatabase::Query(). The main class methods are:
- BOOL Next(): Skips to the next recordset row and fetches the row data from the database
- int AsInteger(int index): returns the value of the corresponding integer field
- CString AsString(index): returns the value of the corresponding string field
- double AsFloat(int index): returns the value of the corresponding float or double field
- void Close(): Closes the recordset
Usage sample
Below please find an example of using these two SQLite access classes:
Download
Please use the following link to download the full SQLite access classes source code.