ÍêÕûµÄVCÏÂSQLiteµÄʹÓÃ
ÎÄÕ·ÖÀà:Êý¾Ý¿â
SQLiteÔÚVCϵÄʹÓã¨×ª£©http://www.sqlite.com.cn/MySqlite/4/523.Html
Ò»¡¢SQLite¼ò½é
SQLite
ÊÇÓÃCÓïÑÔ±àдµÄ¿ªÔ´Êý¾Ý¿â£¬Ö÷ÒªÓÃÓÚǶÈëʽ£¬ÄãÒ²¿ÉÒÔ°ÑËü¼¯³ÉÔÚ×Ô¼ºµÄ×ÀÃæ³ÌÐòÖУ¬Ò²ÓÐÈ˽«ÆäÌæ´úAccess£¬ÓÃ×÷ºǫ́Êý¾Ý¿â¡£
SQLite Ö§³Ö¶àÊýSQL92±ê×¼£¬ÀýÈ磺Ë÷Òý¡¢ÏÞÖÆ¡¢´¥·¢ºÍ²é¿´Ö§³Ö¡£
Ö§³Ö NULL¡¢INTEGER¡¢REAL¡¢TEXT ºÍ BLOB Êý¾ÝÀàÐÍ£¬Ö§³ÖÊÂÎñ¡£
¶þ¡¢ÏÂÔØSQLite
SQLite¿ÉÒÔµ½¹Ù·½Õ¾µãÏÂÔØ
http://www.sqlite.org/download.html
°üÀ¨£ºLinux,Mac OS X, WindowsϵÄÒѱàÒëÎļþÒÔ¼°Ô´´úÂë¡¢°ïÖúÎĵµ¡£
VCÖÐʹÓÃsqlite
SQLite¹Ù·½ÏÂÔØÖ»Ìṩ¸øÎÒÃÇÒ»¸ösqlite3.dll¸úÒ»¸ösqlite3.defÎļþ£¬²¢Ã»ÓÐÌṩÓÃÓÚVC++6.0µÄlibÎļþ£¬¿ÉÒÔÀûÓÃ
sqlite3.defÎļþÉú³É£¬²½ÖèÈçÏ£º
1.½«sqlite3.h£¨D:\sqlite-amalgamation-3_6_23.zip£©¿½±´µ½C:\Program
Files\Microsoft Visual Studio\VC98\IncludeĿ¼Ï£¬Õâʱ±àÒë¿Éͨ¹ý£¬µ«Á´½Ó´íÎó£¬ÒòΪûÓÐLIBÎļþ£¨£©
2.Æô¶¯Ò»¸öÃüÁîÐгÌÐò£¬½øÈëVCµÄ°²×°Ä¿Â¼C:\Program Files\Microsoft Visual
Studio\VC98\Bin£¬ÔÚÕâ¸öĿ¼ÏÂÃæÓÐÒ»¸öLIB.exeÎļþ£¬Ê¹ÓÃËü¾ÍÄÜÉú³Ésqlite3.libÎļþ£¬½«sqlite3.defÎļþ·Å
µ½ÏàͬĿ¼£¬»òÕß¾ø¶Ô·¾¶Ò²¿ÉÒÔ£¬ È»ºóÔÚÃüÁîÐÐÊäÈëÈçÏÂÃüÁ
LIB /MACHINE:IX86 /DEF:sqlite3.def
¸ÃÃüÁîÉú³ÉÁ½¸öÎļþ£ºsqlite3.libºÍsqlite3.exp
ÔËÐиÃÃüÁîʱ£¬Èç¹ûÌáʾÕÒ²»µ½MSPDB60.DLLÎļþ£¬¿É´ÓÆäËüĿ¼¿½±´ÖÁBinĿ¼ÏÂ
3.½«Éú³ÉµÄsqlite3.lib¿½±´µ½LibĿ¼ÏÂ,½«sqlite3.dll¿½±´µ½C:\WINNT\system32Ŀ¼ÏÂ
4.½«sqlite3.lib¼ÓÈëµ½¹¤³ÌÁ´½ÓÖУ¬Project->Settings,LinkÑ¡Ï£¬Object/library
modules×îºóÌíÈësqlite3.lib
D:\sqlitedll-3_6_23ÀïÓÐ.dllºÍ.defÎļþ
Éú³ÉµÄlibÔÚbinÏÂ
ÕâʱÒÔϳÌÐò±ã¿Éͨ¹ýVC±àÒëÁ´½Ó²¢ÔËÐУº
#include <stdio.h>
#include <stdlib.h>
#include <sqlite3.h>
int column_names_printed = 0;
void print_row(int n_values, char** values)
{
int i;
for (i = 0; i < n_values; ++i) {
printf("%10s", values[i]);
&nbs
Ïà¹ØÎĵµ£º
1 TOP
ÕâÊÇÒ»¸ö´ó¼Ò¾³£Îʵ½µÄÎÊÌ⣬ÀýÈçÔÚSQLSERVERÖпÉÒÔʹÓÃÈçÏÂÓï¾äÀ´È¡µÃ¼Ç¼¼¯ÖеÄÇ°Ê®Ìõ¼Ç¼£º
SELECT TOP 10 * from [index] ORDER BY indexid DESC;
µ«ÊÇÕâÌõSQLÓï¾äÔÚSQLiteÖÐÊÇÎÞ·¨Ö´Ðеģ¬Ó¦¸Ã¸ÄΪ£º
SELECT * from [index] ORDER BY indexid DESC limit 0,10;
ÆäÖÐlimit 0,10±íʾ´ÓµÚ0Ìõ¼Ç¼¿ªÊ¼£¬Íùºó ......
¡¡Android SQLite Database±¾´òËã·â×°SQLiteµÄ£¬µ«ÊÇ£¬·¢ÏÖʵ¼ÊÉÏAndroidÒѾ·â×°ÁËÒ»²ã£¬ÓÈÆäÊÇÊý¾ÝµÄÔö¡¢É¾¡¢²é¡¢¸ÄÉÏ£¬¸üÊÇÈç´Ë£¬ËùÒÔ£¬ÎÒºóÀ´Ö»·â×°ÁËÒ»¸öÁ¬½Ó²ã£¬¸ºÔð´ò¿ª¡¢½¨Á¢Êý¾Ý¿â£¬²¢·µ»ØÒ»¸öSQLiteµÄʵÀýÓÃÀ´Íê³ÉÔö¡¢É¾¡¢²å¡¢¸ÄµÈ²Ù×÷¡£
//----------- DBHelper -------------
package utility.db;
import ja ......
@ǶÈëʽ¹ØϵÐÍÊý¾Ý¿âSQLite
Ìصã
1.Ö§³ÖÎåÖÖÊý¾ÝÀàÐÍ null,INTEGER,REAL(¸¡µãÊý),TEXT(×Ö·û´®Îı¾)ºÍBLOB£¨¶þ½øÖÆÎı¾£©Êý¾ÝÀàÐÍ£¬ËäÈ»
ËüÖ»ÓÐÎåÖÖ£¬µ«Êµ¼ÊÉÏsqlite3Ò²½ÓÊÖvarcher(n),char(n),decimal(p,s)µÈÊý¾ÝÀàÐÍ£ ......
SQLite¹Ù·½ÍøÕ¾Àý×Ó£º
#include <stdio.h>
#include <sqlite3.h>
static int callback(void *NotUsed, int argc, char **argv, char **azColName){
int i;
for(i=0; i<argc; i++){
printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
}
printf("\n");
return 0;
}
i ......