这可以通过sqlite3_get_table 函数做到。 1intsqlite3_get_table(2sqlite3 *db,/*An open database*/3constchar*zSql,/*SQL to be evaluated*/4char***pazResult,/*Results of the query*/5int*pnRow,/*Number of result rows written here*/6int*pnColumn,/*Number of result columns written here*...
sqlite3_exec( db , sql , 0 , 0 , &zErrMsg ); int nrow = 0, ncolumn = 0; char **azResult; //二维数组存放结果 //查询数据 /* int sqlite3_get_table(sqlite3*, const char *sql,char***result , int *nrow , int *ncolumn ,char **errmsg ); result中是以数组的形式存放你所查询...
//nResult=sqlite3_exec(db,strSql.c_str(),callback,NULL,&errmsg); char**pResult; intnRow; intnCol; nResult=sqlite3_get_table(db,strSql.c_str(),&pResult,&nRow,&nCol,&errmsg); if(nResult!=SQLITE_OK) { sqlite3_close(db); cout<<errmsg<<endl; sqlite3_free(errmsg); return0; }...
和sqlite3_exec()这种使用回调函数的方式不同,sqlite3_get_table()的功能要显得更加直接。它通过控制语句的传入,直接将参数赋值给指针传出。来看一下函数原型: #include<sqlite3.h> intsqlite3_get_table(sqlite3*db,char*order,char***dResult,int*nRow,int*nColnm,char**errmsg); //参数释义 /* db:数...
和sqlite3_exec()这种使用回调函数的方式不同,sqlite3_get_table()的功能要显得更加直接。它通过控制语句的传入,直接将参数赋值给指针传出。来看一下函数原型:
和sqlite3_exec()这种使用回调函数的方式不同,sqlite3_get_table()的功能要显得更加直接。它通过控制语句的传入,直接将参数赋值给指针传出。来看一下函数原型: #include<sqlite3.h>intsqlite3_get_table(sqlite3*db,char*order,char***dResult,int*nRow,int*nColnm,char**errmsg);//参数释义/* ...
看自己是读操作还是写操作// 如果是写操作就使用sqlite3_exec// 如果是读操作就使用sqlite3_get_table// 4.调用就行了char*errmsg=NULL;sqlite3_exec(db,cmd,NULL,NULL,&errmsg);if(errmsg!=NULL)//如果我们出现错误就会打印errmsg{printf("%s\n",errmsg);}ret=sqlite3_close(db);//---关闭if(ret!=...
CStringstrSql.format(_T(select*frommytablewherefld='+str_value+_T('));的形式,再将它传到sqlite3_get_table()中,问题是,这样写编译通不过,正因为第二个参数是constchar*型的,传个CString当然不行,于是我试图转换一下,写成(constchar*)strSql,或写成(LPCTSTR)strSql,但都没有通过编译。
sqlite3_exec(db,strSql.c_str(),callback,NULL,&errmsg); char** pResult; int nRow; int nCol; nResult = sqlite3_get_table(db,strSql.c_str(),&pResult,&nRow,&nCol,&errm sg); if (nResult != SQLITE_OK) { sqlite3_close(db); cout<<errmsg<<endl; sqlite3_free...
create table if not exists zhiguoxin(id int unique,name char[20],age int); 3.4 删除表格 drop table 表名; //drop table zhiguoxin; 3.5 往表格中插入数据 insert into 表名 values(字段值1,字段值2,字段值3,...); //字段值如果是字符串,必须用''(单引号)括起来 比如...