SQLite Open Source, the code is simple, powerful enough, very extensive use, in this collation of C + + SQLite database programming related to some knowledge.
One. SQLite Build a table
Two. In VS environment, the method of using SQLite in 32-bit program
Three. The use method of SQLite in 64-bit environment
VS Version: VS2012
SQLite version: 3080401
One. SQLite Build a table
?
1 2 3 4 5 6 7 8 9 10 11 |
CD c:sqlite sqlite3.exe mydict.db CREATE TABLE userpwd (ID integer primary key autoincrement,pwd Varchvar (30)); Insert into USERPWD (PWD) VALUES (' AAA '); Insert into USERPWD (PWD) VALUES (' 123456 '); SELECT * from Userpwd; . Quit |
Two. In VS environment, the method of using SQLite in 32-bit program
First download sqlite-dll-win32-x86 get the DLL and DEF file, and then use Lib.exe to manually generate the Lib file needed for vs to be used in the VS environment.
1. Find Mspdb110.dll from the VS IDE and copy it to the directory where the Lib.exe program resides
Mspdb110.dll are stored in the following directory:
C:Program Files (x86) Microsoft Visual Studio 11.0common7ide
2. Enter Lib.exe directory, run command to get Lib
Lib.exe is located in the following directory:
C:Program Files (x86) Microsoft Visual Studio 11.0VCbin
command to generate LIB:
?
1 2 3 4 5 |
C:Program Files (x86) Microsoft Visual Studio 11.0vcbin>lib.exe/machine:ix86/def:c:sqlitesqlite3.def/out:c: Sqlitesqlite3.lib Microsoft (R) Library Manager Version 11.00.60610.1 Copyright (C) Microsoft Corporation. All rights reserved. Creating library C:sqlitesqlite3.lib and Objects C:sqlitesqlite3.exp |
3. Will be copied to the directory of the lib.exe of the Mspdb110.dll to delete, do not clean up the program will be when the error vs.
4. Reference header file, Lib start using database
#include "Sqlite3.h"
#pragma comment (lib, "Sqlite3.lib")
Three. The use method of SQLite in 64-bit environment
SQLite's library is 32-bit, so when compiling the program into 64-bit, there will be an error.
At this time by going to the official website directly download SQLite source file, the source code integrated into the project project in the way you can use it.