SQLite is open-source, simple code, powerful enough, and widely used. In this case, C/C ++ has some knowledge about SQLite database programming.
I. Create SQLite databases and tables
II. In VS environment, 32-bit programs use SQLite
3. How to Use SQLite in a 64-bit environment
VS version: VS2012
SQLite version: 3080401
I. Create SQLite databases and tables
?
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 ('200'); select * from userpwd ;. quit |
II. In VS environment, 32-bit programs use SQLite
First download the sqlite-dll-win32-x86 to the dlland def files, then use lib.exe to manually generate the lib file required for VS can be used in the VS environment.
1. Find mspdb110.dllfrom VS ideand copy it to the directory where the lib.exe program is located.
Mspdb110.dll is stored in the following directory:
C: \ Program Files (x86) \ Microsoft Visual Studio 11.0 \ Common7 \ IDE
2. Enter the directory of lib.exe and run the command to obtain the lib
The Directory of lib.exe is as follows:
C: \ Program Files (x86) \ Microsoft Visual Studio 11.0 \ VC \ bin
Command for generating lib:
?
1 2 3 4 5 |
C: \ Program Files (x86) \ Microsoft Visual Studio 11.0 \ VC \ bin> lib.exe/MACHINE: IX86/DEF: C: \ sqlite \ sqlite3.def/OUT: C: \ sqlite \ sqlite3.lib Microsoft (R) Library Manager Version 11.00.60610.1 Copyright (C) Microsoft Corporation. all rights reserved. creating library C: \ sqlite \ sqlite3.lib and Object C: \ sqlite \ sqlite3.exp |
3. Delete the mspdb110.dll copied to the lib.exe directory. If it is not cleared, VS will report an error during program compilation.
4. reference the header file. lib starts to use the database.
# Include "sqlite3.h"
# Pragma comment (lib, "sqlite3.lib ")
3. How to Use SQLite in a 64-bit environment
SQLite library is 32-bit, so when the program is compiled into 64-bit, an error is reported.
At this time, you can directly download the source code file of SQLite from the official website and integrate the source code into the project to use it.