资源说明:不错,有点用#include
#include "sqlite.h"
int callback( void *p_data, int num_fields, char **p_fields,
char **p_col_names);
main(){
FILE *inp_fp;
int ret;
int nrecs = 0;
char *errmsg;
sqlite *p_db;
unsigned char *sqlcommand;
unsigned char * sqlcreatedb;
sqlcommand="select * from user ;" ;
sqlcreatedb="create table user(id numeric, name text);";
/*建立数据库*/
if ((inp_fp = fopen("./sysdb", "r"))==NULL) {
printf("Cannot find database file !\\n");
printf("Recover the database file ...\\n");
p_db=sqlite_open("./sysdb",0777,0);
sqlite_exec(p_db,sqlcreatedb,0,0,0);
printf("The database file have been recorvered!\\n");
sqlite_close(p_db);
}
/*打开数据库*/
sqlite* p_db=sqlite_open("./sysdb", 0777, 0);
/*选择 user表中的所有记录. */
ret=sqlite_exec(p_db,sqlcommand,callback, &nrecs,
errmsg);
if(ret!=SQLITE_OK){
printf("Error on SELECT: %s.\\n", errmsg);
}
else{
printf("Retrieved %i records.\\n", nrecs);
}
/* 关闭数据库*/
sqlite_close(p_db);
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。