Embedded Database sqlce and SQLite usage (SQLite)

Source: Internet
Author: User

 

2. Use the SQLite database on WinCE:
1. Environment: evc4 + SP4
1 ).Http://sqlite-wince.sourceforge.net/Download the source code of SQLite for Windows CE.
2) create a "wce dynamic-Link Library" project in EVC and name it SQLite.
3) in the following dialog box, select "an empty Windows ce dll Project", click Finish, and then click OK.
4) Copy all *. C *. H *. Def in the source code to the project folder.
5) add all files except shell. C and tclsqlite. C to the project.
6) compile and generate SQLite. lib and SQLite. dll.

2. InHttp://softvoile.com/development/CppSQLite3U/Download the SQLite class encapsulated by C ++ (based on the SQLite. Lib generated above)
Generally, we use SQLite databases on Windows and import basic data. Copy the database to wince and then perform the operation.
This class is the encapsulated Unicode function of SQLite and can be used normally in windows and windows, but note the following:
If you want to use it in windows, because vc6 is a _ MBCS project by default, and if you want to call the Unicode function, generate UTF16 data for normal display of Chinese Characters in windows, you need to extract the compilation parameters of the project from _ MBCS
Changed to Unicode _ Unicode.
3. Now we can operate the SQLite database in evc4:
// Open the database

Cppsqlitedb;
// Open or create a database
DB. Open (L"// Ding. DB");

// Create a table
Db.exe cdml (L "create table sninfo (ID nchar (12), area nvarchar (6), info nvarchar (60), source nchar (6), target nchar (6 )) ");

// Query
Cppsqlite3query q = db.exe cquery (L "select * From sninfo where area = 'guangzhou region '");
Cstring strtemp;
While (! Q. EOF ())
{
Strtemp. format (_ T ("% s-% s"), Q. fieldvalue (0), Q. fieldvalue (3), Q. fieldvalue (4), Q. fieldvalue (1 ));
M_list.addstring (strtemp); // display it in The ListBox control
Q. nextrow ();
}
Q. Finalize ();

DB. Close ();
 
4. here is an introduction to the database operations on SQLite. I have used so many operations now, and I also need to learn more. In Windows, we should note that when using SQLite, do not include Chinese characters in the database path. Otherwise, opening fails. If you must use Chinese characters, convert it to UTF-8. SQLite reads data from the database through UTF-8. (The Chinese path can be used normally under wince, because wince uses unicode encoding by default)

Iii. Postscript
Compared the performance of sqlce and SQLite in querying 50 million records, it can be completed within 2 seconds (I didn't create an index at first, I checked for more than 4 minutes, Dizzy ), you must remember to create an index. Otherwise, query N is slow.
The writing is not good, the level is limited, and the record is not very clear. please correct me if the writing is not correct and learn and make progress together.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.