易截截图软件、单文件、免安装、纯绿色、仅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操作指南(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数据表主键设置Id自增方法

    搞定了一个困扰许久的问题,原来sqlite中的主键也是可以设置为自增的:)方法就是声明为 INTEGER PRIMARY KEY 的字段可以自动增加。
    网上查到资料说,从 SQLite 的 2.3.4 版本开始,如果将一个表中的一个字段声明为 INTEGER PRIMARY KEY,那么只需向该表的该字段插入一个 NULL 值, ......

SQLITE 一个表中数据复制到另一个表中

在SQL中有如下两种方法可以实现将一个表中数据到另一个表中
1> select ... into new_tablename from ... where ...
2> insert (into) old_tablename select ... from ... where ...
区别是前者把数据插入一个新表(先建立表,再插入数据),
后者是把数据插入已经存在的一个表中,我个人喜欢后者,因 ......

Sqlite移植到ARM开发板

Sqlite3.3.8移植
1、下载sqlite-3.3.8.tar.gz源码包,解压tar –zxvf sqlite-3.3.8.tar.gz
2、Cd sqlite-3.3.8
3、手动修改makefile 文件,目录下有一个makefile案例文件: Makefile.linux-gcc
4、重命名一个Makefile文件,cp Makefile.linux-gcc Makefile
5、   打开Makefile文件:vi Makefile
6、&nb ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号