前端之家收集整理的这篇文章主要介绍了
Sqlite3 简单使用,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
CUniEncode un1;
sqlite3 *db;
int result;
char * errmsg = NULL;
char ** dbResult;
int nRow,nColumn;
int i,j;
int index;
result = sqlite3_open("test.db",&db);
if (result != sqlITE_OK)
{
AfxMessageBox(_T("Failed to open database!\n"));
return FALSE;
}
//sqlite3_exec(db,"create table qqq(name text);",NULL,NULL);
CString szName;
CStringA aName;
char * pp;
szName = _T("insert into qq(name) values ('中国');");
wchar_t *wcstring=NULL;
wcstring = szName.AllocSysString();
pp = un1.UnicodetoUTF8(wcstring);
sqlite3_exec(db,pp,NULL);
result = sqlite3_get_table(db,"select * from user;",&dbResult,&nRow,&nColumn,&errmsg);
if (result == sqlITE_OK)
{
index = nColumn;
for (i=0;i<nRow;i++)
{
for (j=0;j<nColumn;j++)
{
CString str,str1;
un1 = dbResult[j];
str = un1.GetWide();
un1 = dbResult[index];
str1 =un1.GetWide();
//AfxMessageBox(str+_T("-----")+str1);
++index;
}
}
}
sqlite3_free_table(dbResult);
sqlite3_close(db);
原文链接:https://www.f2er.com/sqlite/200890.html