SQLite is open-source, simple code, powerful enough, and widely used. In this article, I have compiled some knowledge about SQLite database programming in CC ++.
SQLite is open-source, simple code, powerful enough, and widely used. In this case, C/C ++ has some knowledge about SQLite database programming.
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
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 ('20140901 ');
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:
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.