wxSqlite給sqlite資料庫新增口令
阿新 • • 發佈:2019-02-08
wxSqlite3網上可以搜到下載地址從secure中拷貝出lib,dll,和標頭檔案即可使用
CString strTable[10][6];
sqlite3* db;
char *errmsg;
int nResult = sqlite3_open("db.db",&db);
nResult=sqlite3_key(db,"123",3);
if (nResult != SQLITE_OK)
{
::AfxMessageBox("開啟資料庫失敗!");
return ;
}
else
{
::AfxMessageBox("資料庫開啟成功");
}
int nR,nC;
char szSql[1000]="select * from tb";
char** pResult;
int nRow;
int nCol;
nResult = sqlite3_get_table(db,szSql,&pResult,&nR,&nC,&errmsg);
if (nResult != SQLITE_OK)
{
sqlite3_close(db);
sqlite3_free(errmsg);
return ;
}
nCol=nC;
nRow=nR;
int nIndex=0;
CString strOut="";
for(int i=0;i<nRow+1;i++)
{
strOut="";
for(int j=0;j<nCol;j++)
{
strTable[i][j]=pResult[nIndex];
strOut+=pResult[j];
strOut+=":";
strOut+=pResult[nIndex];
strOut+="\n";
++nIndex;
}
::AfxMessageBox(strOut);
}
sqlite3_free_table(pResult);
sqlite3_close(db);
CDialogEx::OnOK();
}