private void LoadConnection(int id) { ConnectSettings c = S.GetConnection(id); typeCombo.SelectString(c.type); PopulateField("host", c.host); PopulateField("database", c.database); PopulateField("userId", c.user); PopulateField("password", c.password); savePasswordCheckbox.Checked = password.Text != ""; ValidateInput(); }
public static ConnectSettings GetConnection(int id) { using (QSqlLite s = new QSqlLite()) { s.Open("select * from databases where databaseId=" + id); if (s.GetRow()) { ConnectSettings result = new ConnectSettings(); QObject.PopulateFromRow(s, result); return(result); } } return(null); }
public static bool OpenDatabase(int id) { try { ConnectSettings c = S.GetConnection(id); if (c.type == "MySql") { DbInfoMySql dbInfo = new DbInfoMySql(); dbInfo.Connect(c.host, c.database, c.user, c.password); S.initSettings.databaseId = id; db = dbInfo; } else if (c.type == "Sql Server") { DbInfoMsSql dbInfo = new DbInfoMsSql(); dbInfo.Connect(c.host, c.database, c.user, c.password); S.initSettings.databaseId = id; db = dbInfo; } else if (c.type == "SQLite") { DbInfoSqLite dbInfo = new DbInfoSqLite(); dbInfo.Connect(c.database); S.initSettings.databaseId = id; db = dbInfo; } if (db == null) { throw new Exception("unknown error"); } DbInfo.dbId = id; A.appTitle = "Sqrach Pad - " + c.host + " / " + db.databaseName; return(true); } catch (Exception e) { OkBox(form, "Could not open database\r\n" + e.Message, MessageBoxIcon.Error); } return(false); }