/// <summary> /// 创建表 /// </summary> /// <param name="db"></param> /// <param name="ifNotExists"></param> public static void CreateTable(SqLiteHelper db) { Helper = db; string[] colNames = { "ID", "Seq", "Content", "IsSend", "FileName", "CreateTime", "MsgType", "FileSize" }; string[] colTypes = { "INTEGER PRIMARY KEY", "TEXT", "TEXT", "Boolean", "TEXT", "TEXT", "INTEGER", "TEXT" }; db.CreateTable(TABLE_NAME, colNames, colTypes); }
public static void UpdateTable(SqLiteHelper db) { int result = db.ExecuteScalar("SELECT count(*) from sqlite_master where type='table' and name='" + TABLE_NAME + "'"); if (result != 0) { //db.ExecuteScalar(" DROP TABLE " + TABLE_NAME); string Template = "ALTER TABLE {0} ADD {1} {2}"; StringBuilder sb = new StringBuilder(); sb.AppendFormat(Template, TABLE_NAME, "MsgId", "TEXT"); db.ExecuteSql(sb.ToString()); } //CreateTable(db); }
public DaoSession(string connectionString, int version) { db = new SqLiteHelper(connectionString); InitDataBase(version); messageDao = new MessageDao(); }