SQLite3 MFC Wrapper

前端之家收集整理的这篇文章主要介绍了SQLite3 MFC Wrapper前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Introduction

Here is another wrapper for the famous SQLite3 database engine. While there are several other wrappers available here at Code Project,I don't believe they support MFC/Unicode or have the results tested on a Pocket PC.

The wrapper source code is based on the sqliteWrapper source produced by rene.nyffenegger@adp-gmbh.ch. I altered the original source while packaging it for use with Microsoft MFC. My primary objective in this exercise was to make the wrapper suitable for both MCBS and Unicode because Unicode is native to the Pocket PC. There are four key differences between this wrapper and the author's original source.

  • First,all the instances of std::string were converted to Microsoft's generic string pointers using LPCTSTR. This should be familiar to developer's accustomed to working with MFC. This also means that you should rely heavily on the Microsoft TEXT or _T macros for hard-coded character strings should you wish to maintain portability between the desktop and the Pocket PC.
  • Second,I have changed the class sqliteStatement to CsqlStatement and sqliteWrapper to CDbsqlite. This was primarily a matter of preference since most MFC developer's recognize Microsoft's conventions for the "Cx" nomenclature.
  • Third,I removed exception handling from the wrapper. Windows CE does not support the traditional try, catch and throw paradigm so you are basically on your own with respect to error handling.
  • Finally,I have added the header sqlite3i.h with typedefs to the varIoUs sqlite3.h functions. These type definitions are "internal" accessors to the sqlite3 functions conditionally utilizing either the UTF-8 or UTF-16 variation during compilation. For your entertainment,I incorporated a pragma in the header to inform you when you are compiling Unicode or MCBS.

Care and Feeding

The test programs provided here are simple MFC dialog applications incorporating two buttons,an edit Box and a list control. The "Create" button is used to populate the database with three entries. The "review" button is used to populate the list control with the database records. It is acceptable to click the "Create" button more than once. You may even wish to do so to observe any errors reported. The edit Box is used simply for status info.

This code was tested on a Windows desktop and on a Pocket PC. As part of my test,I moved the database created by the Pocket PC to my desktop and then reviewed it using the desktop application.

Free with your purchase

The ZIP file contains the source code for the altered wrapper as well as code for both a desktop and Pocket PC application. The projects that I have provided include:

  1. Project to create the w32sqlite3.dll.
  2. Project to create the wcesqlite3.dll.
  3. Project to create the desktop test application.
  4. Project to create the Pocket PC test application.

As you might gather from this list,you must first build the DLL files for use with the test applications that I have provided. In order to do this,you should obtain the source from the SQLite Download Page for the W32 DLL and deposit it into the sqlite3 directory. You should obtain the source for the WCE DLL from the SQLite for Windows CE site and deposit it into the wince directory.

Once you have constructed the two DLL files,move them and their corresponding .lib files to the LIB directory. The application projects will search for these files in that location.

Warnings and disclaimers

  • All of these projects assume that you are experienced with MFC development and proficient in navigating Microsoft's IDE to configure the complier.
  • All of the projects provided here are dependent upon the directory structure stored in the zip file. If you deviate from this structure,please do not submit reports that " compilation fails because the compiler cannot locate the applicable header files".
  • The desktop solutions were created using Visual Studio 2003,so please don't submit questions informing me that you cannot load the project with a prior version of VC or a different compiler.
  • The CE projects were created using eMbedded Visual C++ v4.00,so please don't submit questions informing me that you cannot load the project using a different compiler.
  • The sample code is pure MFC so please don't submit comments about any notions you may have about portability or code bloat. The whole purpose here was to use sqlite on Windows CE using MFC.
  • This code was tested on a Win2K desktop and a Symbol PDT-8100 with Microsoft Pocket PC Version 4.20.0. Your results on anything less are anybody's guess.
  • These projects were compiled with the source code from sqlite3 Version 3.2.8 and sqlite for Windows CE Version 3.2.2. Problems compiling with future versions are most likely due to missing source files that should be included in the project.
原文链接:https://www.f2er.com/sqlite/202106.html

猜你在找的Sqlite相关文章