Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQLiteÊý¾Ý¿âʹÓÃ×ܽá

1.ÔÚSQLiteÖвåÈ뵱ǰʱ¼ä,±äÁ¿¶¨Òå²»Óöà˵
char *sql = sqlite3_mprintf("insert into Log VALUES(datetime('now', 'localtime'), '%q', '%q')", cUser, cLogContent);
int ret = sqlite3_exec(Sqlite3, sql, NULL, NULL, &pErrMsg);
ÒÔÔ·ÝΪµ¥Î»Í³¼Æ³ö·ûºÏµ±Ç°Ô·ݵļǼ, TimeΪÊý¾Ý¿âÖÐ×Ö¶ÎÃû:
char *sql = sqlite3_mprintf("select * from Log where Time>=datetime('now','start of month') order by Time DESC");
sqlite3_prepare(sqlite3_db, sql, -1, &pStmt, &pzTail);
int ret = sqlite3_step(pStmt);
while (ret == SQLITE_ROW)
{
    ...
    ret = sqlite3_step(pStmt);
}
ÒÔʱ¼ä¶ÎÀ´²éѯ,½çÃæÌáʾµÄʱ¼äΪYYYY-MM-DD¸ñʽ,cStartTime, cEndTimeΪchar *´¢´æµÄÊÇʱ¼äYYYY-MM-DD:
char *sql = sqlite3_mprintf("select * from Log where Time between datetime('%q','start of day') and datetime('%q','start of
day','+1 day') order by Time DESC", cStartTime, cEndTime);
sqlite3_prepare(sqlite3_db, sql, -1, &pStmt, &pzTail);
int ret = sqlite3_step(pStmt);
while (ret == SQLITE_ROW)
{
    ...
    ret = sqlite3_step(pStmt);
}
2.×¢Òâ:ÇмÇÔÚ´íÎó´¦ÀíÖÐ,Ò²Òª°Ñ´ò¿ªµÄÊý¾Ý¿â¹Ø±Õ,²»È»´øÀ´²»±ØÒªµÄÂé·³
3.´óÁ¿Êý¾Ý´¦ÀíÊÇ,ÓÃÊÂÎñ,Ê°빦±¶
4.ÓÃsqlite3_open16(L"data.db", &m_sqlite3);´ò¿ªÊý¾Ý¿âʱ,±ØÐë¼ÓÉÏL


Ïà¹ØÎĵµ£º

sqlceÓësqliteÊý¾Ý¿âµÄ±È½Ï

×î½üÓÉÓÚÏîÄ¿ÐèÒª£¬ ÒªÔÚwince4.2, wince5.0, mobileÈýÖÖ»úÐÍÉÏÃæ×ö´óÊý¾ÝÁ¿µÄ²éѯ£¬³õ²½¹À¼ÆÔÚ50W-500WÌõ¼Ç¼֮¼ä¡£
ÓÉÓÚÒÔÇ°×ömobile5µÄÊý¾Ý¿âÏîÄ¿Ö÷ÒªÊDzÉÓÃC#À´Ð´£¬¶øÇÒÊý¾ÝÁ¿Ò²¶¥¶à¼¸ÍòÌõ£¬ËùÒÔ£¬ÎªÁËÈ·±£ÏîÄ¿ºóÆÚÉÙ×ßÍä·£¬ÎÒÌØÒâ×öÁËÒ»ÏÂÒƶ¯Êý¾Ý¿âÐÔÄܲâÊÔ¡£ÏÂÃæÊÇÕâÖܵŤ×÷¼Ç¼¡£¹©´ó¼Ò²Î¿¼¡£
Ò». ÓÉÓÚwince4.2 ......

QtopiaÖÐʹÓÃSQLite×ܽἰSQLiteÖд洢ÖÐÎIJÙ×÷

¡¾¹¤×÷»·¾³£º»ùÓÚÓÑÉÆÖ®±Ûmini2440¿ª·¢°å+Qtopia2.2°æ±¾+RedHat9+SQLite-3.3.6¡¿
1.QtopiaÖÐʹÓÃSQLite
ÓÉÓÚQt2²»Ö§³ÖÊý¾Ý¿â²Ù×÷£¬£¨Qt3°æ±¾¾ÍÌṩÁËÖ§³ÖÊý¾Ý¿â²Ù×÷µÄÀ࣬µ«ÊÇQtopia2±È½Ï¾­µä£¬ÊÇ»ùÓÚQt2µÄ£¬Ã»°ì·¨£¡£©ËùÒÔÔÚQt/Qtopia³ÌÐòÖÐÐèÒªÊý¾Ý¿âʱ£¬¿ÉÒÔ¿¼ÂÇÔÚQtÖÐʹÓÃLinuxϲÙ×÷SQLiteÊý¾Ý¿âµÄ·½·¨¡££¨±í´ïµÄÓе ......

sqlite½â¾öÖÐÎÄ·¾¶ÎÊÌâ


// sqlite½â¾öÖÐÎÄ·¾¶ÎÊÌâ,ÒÔÇ°Ñо¿sqliteʱºòÓöµ½µÄÖÐÎÄ·¾¶ÎÊÌâµÄ½â¾ö·½·¨
// AnsiString cbÖеÄ×Ö·û´®Àà,ÆäËü±àÒëÆ÷ÓÃstd::stringÌæ»»¼´¿É.
// MultiByteToWideCharÊÇwindows api
AnsiString fileName;   
int strSize = fileName.Length();
char *ansi = new char[strSize+1];
wchar_t *unico ......

sqlite³£¼ûÎÊÌâ

 (1) ÈçºÎ½¨Á¢×Ô¶¯Ôö³¤×Ö¶Î?
¼ò¶Ì»Ø´ð£ºÉùÃ÷Ϊ INTEGER PRIMARY KEY µÄÁн«»á×Ô¶¯Ôö³¤¡£
³¤Ò»µãµÄ´ð°¸£º Èç¹ûÄãÉùÃ÷±íµÄÒ»ÁÐΪ INTEGER PRIMARY KEY£¬ÄÇô£¬ ÿµ±ÄãÔÚ¸ÃÁÐÉϲåÈëÒ»NULLֵʱ£¬ NULL×Ô¶¯±»×ª»»ÎªÒ»¸ö±È¸ÃÁÐÖÐ×î´óÖµ´ó1µÄÒ»¸öÕûÊý£¬Èç¹û±íÊǿյģ¬ ½«»áÊÇ1¡£ (Èç¹ûÊÇ×î´ó¿ÉÄܵÄÖ÷¼ü 9223372036854775807 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ