public void CreateDataBase(string dbPath, string pwd) { if (!File.Exists(dbPath)) { SqliteConnection.CreateFile(dbPath); if (string.IsNullOrEmpty(pwd)) { using (SqliteConnection conn = new SqliteConnection("Data Source=" + dbPath)) { try { conn.SetPassword(pwd); } catch { conn.Close(); throw; } finally { conn.Close(); } } } } else throw new Exception("已经存在名叫:" + dbPath + "的数据库!"); }
public string Connect(string dbFile, string password) { this.dbFile = dbFile; var dbStr = "DbLinqProvider=Sqlite;Data Source=" + dbFile; Debug.Log("Connect:" + dbStr); conn = new SqliteConnection (dbStr); try { conn.SetPassword(password); conn.Open (); return ""; } catch (Exception err) { Debug.Log(err); conn = null; return err.ToString(); } }