Home > Database > Mysql Tutorial > body text

SQLite编程相关

WBOY
Release: 2016-06-07 17:35:51
Original
955 people have browsed it

SQLite开源,代码简单,功能足够强大,使用非常广泛,在这 整理下C/C++对SQLite数据库编程相关的一些知识。

SQLite开源,代码简单,功能足够强大,使用非常广泛,在这 整理下C/C++对SQLite数据库编程相关的一些知识。

一。 SQLite建库建表

二。 VS环境下,32位程序使用SQLite的方法

三。 64位环境下SQLite的使用方法

 

VS版本为: VS2012

SQLite版本: 3080401

一。 SQLite建库建表

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

二。 VS环境下,32位程序使用SQLite的方法

 

首先下载 sqlite-dll-win32-x86 得到dll与def文件,然后使用lib.exe手工生成VS所需的 lib 文件即可在VS环境中使用了。

1. 从VS IDE下找到mspdb110.dll,复制到lib.exe程序所在目录下

mspdb110.dll 存放在下面目录:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE

2. 进入lib.exe所在目录,运行命令得到lib

lib.exe所在目录如下:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin

生成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.

  正在创建库 C:\sqlite\sqlite3.lib 和对象 C:\sqlite\sqlite3.exp

3. 将复制到lib.exe所在目录的mspdb110.dll给删除掉,不清理的话在编译程序时会VS会报错。

 

4. 引用头文件,lib开始使用数据库

#include "sqlite3.h"
#pragma comment(lib,"sqlite3.lib")

 

三。 64位环境下SQLite的使用方法

SQLite的库是32位的,所以编译程序成64位时,,会有报错。

这时通过去官网直接下载SQLite的源码文件,将源代码集成至项目工程中的方式即可使用它。

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!