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

Unity3d ʹÓÃsqliteÊý¾Ý¿â

dbAccess.js
import System.Data; // we import our data class
import Mono.Data.SqliteClient; // we import our sqlite client

class dbAccess {
// variables for basic query access
private var connection : String;
private var dbcon : IDbConnection;
private var dbcmd : IDbCommand;
private var reader : IDataReader;

function OpenDB(p : String){
connection = "URI=file:" + p; // we set the connection to our database
dbcon = new SqliteConnection(connection);
dbcon.Open();
}

function BasicQuery(q : String, r : boolean){ // run a baic Sqlite query
dbcmd = dbcon.CreateCommand(); // create empty command
dbcmd.CommandText = q; // fill the command
reader = dbcmd.ExecuteReader(); // execute command which returns a reader
if(r){ // if we want to return the reader
return reader; // return the reader
}
}

function CreateTable(name : String, col : Array, colType : Array){ // Create a table, name, column array, column type array
var query : String;
query = "CREATE TABLE " + name + "(" + col[0] + " " + colType[0];
for(var i=1; i<col.length; i++){
query += ", " + col[i] + " " + colType[i];
}
query += ")";
dbcmd = dbcon.CreateCommand(); // create empty command
dbcmd.CommandText = query; // fill the command
reader = dbcmd.ExecuteReader(); // execute command which returns a reader

}

function InsertIntoSingle(tableName : String, colName : String, value : String){ // single insert
var query : String;
query = "INSERT INTO " + tableName + "(" + colName + ") " + "VALUES (" + value + ")";
dbcmd = dbcon.CreateCommand(); // create empty command
dbcmd.CommandText = query; // fill the command
reader = dbcmd.ExecuteReader(); // execute command which returns a reader
}

function InsertIntoSpecific


Ïà¹ØÎĵµ£º

½«Í¼Æ¬µÈÎļþ±£´æµ½sqliteÖУ¨c#£©

 SqLite.netµÄdllΪSystem.Data.SQLite.dll£¬ÕâÖÖdll·ÖΪ32λ¡¢64λºÍÊÊÓÃÓÚcompactframeworkÈýÖÖ£¬ÔÚÒýÓÃʱҪעÒ⣬ѡÔñÕýÈ·µÄdll¡£
½«Òª±£´æÍ¼Æ¬µÄ×Ö¶ÎÀàÐÍÉèΪblob¡£´úÂëÈçÏ£º
private void savePicture£¨£©
{
using (SQLiteConnection cnn = new SQLiteConnection(dbPath))
......

SQLite²Ù×÷Ö¸ÄÏ(SQLite version 3.6.21)

1¡¢.back ?DB? FILE  ±¸·ÝDB(ĬÈÏΪmain)µ½Îļþ
2¡¢.bail ON|OFF  Óöµ½Ò»¸ö´íÎó¿ÛÍ£Ö¹£¬¸ÃֵĬÈÏΪOFF
3¡¢.databases  Áоٸ½¼Óµ½Êý¾Ý¿âµÄÊý¾Ý¿âÃûºÍÎļþÃû
4¡¢.dump ?TABLE? ...  ÓÃSQLÎı¾¸ñʽÁоÙÊý¾Ý¿â£¬Èç¹ûÖ¸¶¨TABLE£¬½ö½öÁÐ¾ÙÆ¥ÅäµÄ±í£¬LIKEÀàÐÍTABLE
5¡¢.echo ON|OFF  ÉèÖÃechoµÄ״̬ ......

SQLITEÈëÃÅ Öð²½½²½âSQLITEÃüÁîÐÐ(Ò»)

Ê×ÏÈ×öµãÆÌµæËµÃ÷£º
sqlite³ÌÐòͨ¹ý²éÕÒ·ÖºÅ(;)À´¾ö¶¨Ò»¸öSQLÓï¾äµÄ½áÊø,ËùÒÔÒªÖ´ÐÐSQLÓï¾äÇëÈ·±£ÔÚSQLÓï¾äºóÓзֺÅ(;).Èç¹ûÄãÊ¡ÂԷֺţ¬sqlite3½«¸øÄãÒ»¸öÁ¬ÐøµÄÃüÁîÌáʾ·û(...> )²¢µÈÄã¸øµ±Ç°µÄSQLÃüÁîÌí¼Ó¸ü¶àµÄÎÄ×Ö¡£Õâ¸öÌØµãÈÃÄãÊäÈë¶àÐеĶà¸öSQLÓï¾ä.µ«µãºÅ(.)ÃüÁî²»Òª·ÖºÅ(;).ctrl+c¿ÉÒÔ½áÊøµ±Ç°ÃüÁî¡£
ÔÚdos´ ......

SQLITEÊý¾Ý±íÖ÷¼üÉèÖÃId×ÔÔö·½·¨

    ¸ã¶¨ÁËÒ»¸öÀ§ÈÅÐí¾ÃµÄÎÊÌ⣬ԭÀ´sqliteÖеÄÖ÷¼üÒ²ÊÇ¿ÉÒÔÉèÖÃΪ×ÔÔöµÄ£º£©·½·¨¾ÍÊÇÉùÃ÷Ϊ INTEGER PRIMARY KEY µÄ×ֶοÉÒÔ×Ô¶¯Ôö¼Ó¡£
    ÍøÉϲ鵽×ÊÁÏ˵£¬´Ó SQLite µÄ 2.3.4 °æ±¾¿ªÊ¼£¬Èç¹û½«Ò»¸ö±íÖеÄÒ»¸ö×Ö¶ÎÉùÃ÷Ϊ INTEGER PRIMARY KEY£¬ÄÇôֻÐèÏò¸Ã±íµÄ¸Ã×ֶβåÈëÒ»¸ö NULL Öµ£¬ ......

Unity3d ÖÐÎÄÊäÈëÊä³ö ²éѯsqliteÊý¾Ý¿â

CnGuiDB.js
var db : dbAccess;
public var mskin : GUISkin;
private var mstring : String;
var inputStr;
function Start(){
inputStr = "1";
}
function search(mid)
{
db = new dbAccess();
db.OpenDB("db1.db");
var tableName = "myTable";
// table name, I want to return everyo ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ