当前位置: 代码迷 >> VC >> sqlite3 sqlite3_get_table()解决方法
  详细解决方案

sqlite3 sqlite3_get_table()解决方法

热度:3854   发布时间:2013-02-25 00:00:00.0
sqlite3 sqlite3_get_table()
最近在做一个wince小程序,用到sqlite3,用到查询时疑惑不解,请助大家.
sqlite3有个sqlite3_get_table()的函数,可执行查询并返回结果,其原型为:
sqlite3_get_table(sqlite3*,const char* sql,char*** resultp,int* nrow,int* ncolumn,char** errmsg);

其中第二个参数为const char*类型,如此说来,我构造的sql语句是不是只能是:
select * from mytable where fld ='我'.

但实际中经常要用到变量作为查询条件,因此,我不得不构造一个字符串写成:
CString strSql.format(_T(select * from mytable where fld= '"+str_value + _T("'"));的形式,再将它传到sqlite3_get_table()中,问题是,这样写编译通不过,正因为第二个参数是const char*型的,传个CString当然不行,于是我试图转换一下,写成(const char*)strSql,或写成(LPCTSTR)strSql,但都没有通过编译。

如何是好呢?难道我不用where查询条件,返回所有记录吗?表中可有近十万条数据...
哪位哥哥姐姐有办法,指点一下,先谢了。


------解决方案--------------------------------------------------------
sqlite3_get_table() 这个方法是不被推荐的

http://topic.csdn.net/u/20081103/20/dc5f7429-baaf-40a1-9a51-3bc5c7439d3a

用 sqlite3_exec
  相关解决方案