public int CreateTables() { try { int result = 0; using (DbConnection = new SQLitePersistence(DbConnectionSettings)) { if (DbConnection.IsConnected()) { using (DbCommand = new SQLiteCommand()) { string sql = "CREATE TABLE if not exists HostSettings " + " (" + "ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " + "DataSource VARCHAR(200) NULL, " + "DatabaseName VARCHAR(100) NULL, " + "UserLogin VARCHAR(30) NULL," + "Password VARCHAR(30) NULL," + "SALogin VARCHAR(30) NULL," + "SAPassword VARCHAR(30) NULL," + "BaseKey TEXT NULL" + ")"; DbCommand.CommandText = sql; result = DbConnection.ExecuteCommand(DbCommand); // Build HostOptions Table sql = "CREATE TABLE if not exists HostOptions " + " (" + "ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " + "SessionTimeout int NULL," + "LockTimeout int NULL" + ");"; DbCommand.CommandText = sql; result = DbConnection.ExecuteCommand(DbCommand); // Build HostOptions Table sql = "CREATE TABLE if not exists Accounting" + " (" + "InterfaceId int NULL," + "Setting1 TEXT NULL," + "Setting2 TEXT NULL," + "Setting3 TEXT NULL," + "Setting4 TEXT NULL," + "Setting5 TEXT NULL" + ");"; DbCommand.CommandText = sql; result = DbConnection.ExecuteCommand(DbCommand); // Remains Last to indicate setup complete // Insert Defaults sql = "SELECT COUNT(ID) AS COUNT FROM HostOptions"; DbCommand.CommandText = sql; int count = Convert.ToInt32(DbConnection.ExecuteScalar(DbCommand)); if (count <= 0) { sql = "insert into HostOptions (SessionTimeout, LockTimeout) Values(480,30);"; DbCommand.CommandText = sql; result = DbConnection.ExecuteCommand(DbCommand); } } } } return result; }catch { throw; } }