//²åÈë¼°¸üвÙ×÷
int nRet = 0;
sqlite3 * db = NULL;
CString strFilePath; //Êý¾Ý¿â´æ´¢Â·¾¶
//·¾¶¸³Öµ£¨Ê¡ÂÔ£©
//Á¬½ÓÊý¾Ý¿â
nRet = sqlite3_open16(strFilePath, &db); //Óм¸¸ö´ò¿ªº¯Êý¿É¹©µ÷Óã¬Ê¹ÓÃWCHARÀàÐÍ·¾¶ÓÃÕâ¸ö
if(nRet != SQLITE_OK)
{
LogD(_Q_D,L"Êý¾Ý¿â´ò¿ªÊ§°Ü");
return -4;
}
CString strSQLSentence;
char *szSQLSentence = NULL;
×éÖ¯SQLÓï¾ä
**********************
{
//¸üвÙ×÷
strSQLSentence.Format(L"update tbl_ad set AD_TITLE='%s', AD_INFO='%s', BEGIN_TIME='%s', END_TIME='%s' where AD_ID='%s';", strADTitle, strADInfo, strADBeginTime, strADEndTime, strADId);
}
{
//²åÈë²Ù×÷
strSQLSentence.Format(L"insert into tbl_Advertisement values('%s','%s','%s','%s','%s');", strADId, strADTitle, strADInfo, strADBeginTime, strADEndTime);
}
**********************
//½«SQLÓï¾äת»»³Ésqliteº¯ÊýÄÜÖ´ÐеÄUTF8¸ñʽ
nLen = 0;
nLen = WideCharToMultiByte(CP_UTF8, 0, strSQLSentence, -1, NULL, 0, NULL, 0);
szSQLSentence = new char[nLen+1];
if (szSQLSentence == NULL)
{
return -6;
}
memset(szSQLSentence, 0, nLen+1);
WideCharToMultiByte(CP_UTF8, 0, strSQLSentence, -1, szSQLSentence, nLen+1, NULL, 0);
//Ëø¶¨Êý¾Ý¿â
if(SQLiteLock(L"terminalplat.db",30*1000) == 0) //SQLiteLockΪ×ÔдµÄÒ»Ì×Ëø»úÖÆÖеĺ¯Êý
{
// ×¼±¸Ö´ÐÐSQL
nRet = sqlite3_exec( db, "begin;", 0, 0, 0);
if(nRet == SQLITE_OK)
{
BOOL bSuccess = TRUE;
char * pErrMsg = NULL;
// Ö´ÐÐSQL
nRet = sqlite3_exec( db, szSQLSentence, 0, 0, &pErrMsg);
if(nRet != SQLITE_OK)
 
»¹Êdzõ̽£¬×öµÄÏîÄ¿ÒªÓõ½ÇáÇɵı¾µØÊý¾Ý¿â£¬ÓÚÊÇÕÒÁË sqlite 3 ÊÔÓÃÖ®£¬»¹²»´í£¬¹»ÇáÇÉ¡£
ÉÏÕâ¶ùÈ¥ÏÂÔسÌÐòºÍ²é¿´Îĵµ£º http://www.sqlite.org/download.html
Õâ»Ø¿ª·¢ÓõÄÊÇ C#£¬ÓÚÊÇÕÒÁ˸ö.NETµÄ¿â Finisar.SQLite £¬µ½Õâ¶ùÈ¥ÔØ http://adodotnetsqlite.sourceforge.net/
Òª¼ÇµÄÒ²²»ÊÇʲô´ó²»Á˵Ķ«Î÷£¬Ê¾ÀýÍøÕ¾É϶ ......