• 7501阅读
  • 6回复

请问在qt-2.3.7中如何使用sqlite数据库啊?? [复制链接]

上一主题 下一主题
离线yanyf2006
 
只看楼主 倒序阅读 楼主  发表于: 2006-07-18
尊敬的朋友们:
      我已在arm板上装好了sqlite-2.8.17。但怎样在QT-2.3.7中用还不知道。具体的说是不知道怎么把sqlite的库加进去。请各位大侠帮帮忙啊。谢谢!
[ 此贴被XChinux在2006-07-19 08:31重新编辑 ]
离线shiroki

只看该作者 1楼 发表于: 2006-07-19
qte里没发现sqlite的接口,qtopia2里倒是有的, 源码包里可以搜到
--
shiro is White
ki is tree
http://www.cuteqt.com
论坛 http://www.cuteqt.com/bbs
博客 http://www.cuteqt.com/blog
博客镜像: http://sites.cuteqt.com/cuteqt
Linux/Qt/嵌入式讨论群 http://qun.qq.com/air/5699823
离线yanyf2006
只看该作者 2楼 发表于: 2006-07-20
是另外的源码包,还是在qtopia2的源码中,我找了一下好象没有,能提供具体的途径吗?
离线yanyf2006
只看该作者 3楼 发表于: 2006-07-20
解决了 深思熟虑   大家看看这个文档就明白了.
Below is a simple C program that demonstrates how to use the C/C++ interface to SQLite. The name of a database is given by the first argument and the second argument is one or more SQL statements to execute against the database. The function calls to pay attention to here are the call to sqlite3_open() on line 22 which opens the database, sqlite3_exec() on line 27 that executes SQL commands against the database, and sqlite3_close() on line 31 that closes the database connection.

#include <stdio.h>
#include <sqlite3.h>     这里关键所在

static int callback(void *NotUsed, int argc, char **argv, char **azColName){
int i;
for(i=0; i<argc; i++){
  printf("%s = %s\n", azColName, argv ? argv : "NULL");
}
printf("\n");
return 0;
}

int main(int argc, char **argv){
sqlite3 *db;
char *zErrMsg = 0;
int rc;

if( argc!=3 ){
  fprintf(stderr, "Usage: %s DATABASE SQL-STATEMENT\n", argv[0]);
  exit(1);
}
rc = sqlite3_open(argv[1], &db);
if( rc ){
  fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
  sqlite3_close(db);
  exit(1);
}
rc = sqlite3_exec(db, argv[2], callback, 0, &zErrMsg);
if( rc!=SQLITE_OK ){
  fprintf(stderr, "SQL error: %s\n", zErrMsg);
  sqlite3_free(zErrMsg);
}
sqlite3_close(db);
return 0;
}

在qte平台上 这么编写应用程序就行.
离线backup
只看该作者 4楼 发表于: 2006-08-05
请问如何获取sqlite3.h文件的呢? 如何编译出for arm的sqlite呢?
如果应用程序发布时,需要在目标板(S3C2410)安装哪些库文件呢?
离线dduan2002cn

只看该作者 5楼 发表于: 2006-09-20
这个属于直接调用sqlite,qte-3.3.X以下的没有qt封装好的sqlite的接口,自己写个吧,效率会更高.
离线fzusuper
只看该作者 6楼 发表于: 2009-03-13
可否留个联系方式?我也碰到类似问题
快速回复
限100 字节
 
上一个 下一个