#include<stdio.h> <stdlib.h> "sqlite3.h" #definesqlITE3_STATIC externintsqlite3_key(sqlite3*db,constvoid*pKey,85)">intnKey); staticint_callback_exec(void* notused,85)">intargc,85)">char** argv,85)">char** aszColName) { inti; for( i=0; i<argc; i++ ) { printf("%s = %s\r\n",aszColName[i],argv[i] == 0 ?"NUL": argv[i] ); } return0; } intmain(char* argv[]) { char* ssql; char* pErrMsg = 0; intret = 0; sqlite3* db = 0; //创建数据库 ret = sqlite3_open("d:\\encrypt.db",&db); 添加密码 ret = sqlite3_key( db,"dcg",3 ); 在内存数据库中创建表 ssql ="create table class(namevarchar(20),student);"; sqlite3_exec( db,ssql,_callback_exec,&pErrMsg ); 插入数据 ssql ="insert into class values('mem_52911','zhaoyun');"; sqlite3_exec( db,95)">取得数据并显示 ssql ="select * from class;"; sqlite3_exec( db,95)">关闭数据库 sqlite3_close(db); db = 0; return0; } |