易截截图软件、单文件、免安装、纯绿色、仅160KB

SQLite数据库使用总结

1.在SQLite中插入当前时间,变量定义不用多说
char *sql = sqlite3_mprintf("insert into Log VALUES(datetime('now', 'localtime'), '%q', '%q')", cUser, cLogContent);
int ret = sqlite3_exec(Sqlite3, sql, NULL, NULL, &pErrMsg);
以月份为单位统计出符合当前月份的记录, Time为数据库中字段名:
char *sql = sqlite3_mprintf("select * from Log where Time>=datetime('now','start of month') order by Time DESC");
sqlite3_prepare(sqlite3_db, sql, -1, &pStmt, &pzTail);
int ret = sqlite3_step(pStmt);
while (ret == SQLITE_ROW)
{
    ...
    ret = sqlite3_step(pStmt);
}
以时间段来查询,界面提示的时间为YYYY-MM-DD格式,cStartTime, cEndTime为char *储存的是时间YYYY-MM-DD:
char *sql = sqlite3_mprintf("select * from Log where Time between datetime('%q','start of day') and datetime('%q','start of
day','+1 day') order by Time DESC", cStartTime, cEndTime);
sqlite3_prepare(sqlite3_db, sql, -1, &pStmt, &pzTail);
int ret = sqlite3_step(pStmt);
while (ret == SQLITE_ROW)
{
    ...
    ret = sqlite3_step(pStmt);
}
2.注意:切记在错误处理中,也要把打开的数据库关闭,不然带来不必要的麻烦
3.大量数据处理是,用事务,事半功倍
4.用sqlite3_open16(L"data.db", &m_sqlite3);打开数据库时,必须加上L


相关文档:

[收拢] 用sqlite 执行标准 sql 语法

http://www.umgr.com/blog/PostView.aspx?bpId=36294
 1. 执行sql语句
int sqlite3_exec(sqlite3*, const char *sql, sqlite3_callbacksql 语法
, void *,  char **errmsg );
这就是执行一条 sql 语句的函数。
第1个参数不再说了,是前面open函数得到的指针。说了是关键数据结构。
第2个参数const char ......

sqlite解决中文路径问题


// sqlite解决中文路径问题,以前研究sqlite时候遇到的中文路径问题的解决方法
// AnsiString cb中的字符串类,其它编译器用std::string替换即可.
// MultiByteToWideChar是windows api
AnsiString fileName;   
int strSize = fileName.Length();
char *ansi = new char[strSize+1];
wchar_t *unico ......

Sqlite 嵌入式数据库移植和使用

 
1.    源代码的获取
sqlite是一个功能强大、体积小运算速度快的嵌入式数据库,采用了全C语言封装,并提供了八十多个命令接口,可移植性强,使用方便。
下载地址:http://sqlite.org/download.html
sqlite源代码:sqlite-3.6.17.tar.gz
2.    sqlite移植到x86 for linu ......

在sqlite数据库中,int类型不等于integer数据类型

这些天一直在忙销售管理软件易卖通客户端的程序编写,由于需要采用本地数据缓存机制来提高程序的数据访问效率,所以需要在客户端使用一个小巧的本地数据库。这个数据库当然要小而精悍的。我也不想做强盗,于是就选择Sqlite吧——文件数据库,只要一个Sqlite.dll就可以操作数据库。
不得不趁人本人是有点偷懒,Ad ......

SQLite Tutorial in PHP

 
SQLite Tutorial in PHP
SQLite is an SQL database manager used locally or on a website, and compatible
in particularly with PHP.
Summary
Installing SQLite and creating a database
.
Installing SQLite. Verifying the installation by creating a base.
Creating and using a SQLite tabl ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号