public MainDBClass() { sqliteProvider = new DB_Class_SQLite.DBClassSQLite(); string conString = string.Empty; int bUseSQlServer = 0; DBClassSQLite db1 = new DBClassSQLite(); db1.OpenDB(); if (db1.isTableExist("tb_SqlServer_Info")) { db1.getSqlServerInfo(out conString, out bUseSQlServer); } db1.CloseDB(); if ((bUseSQlServer == 1) && (!string.IsNullOrEmpty(conString))) { useDb = dbUsedType.db_SqlServer; sqlServerProvider = new DBClassSqlServer.DBSqlServer(DBClass_SQLServer.UtilSqlServer.ConvertConnectionString(conString)); try { OpenDB(); CloseDB(); } catch { useDb = dbUsedType.db_SqlLite; ErrorMessage.ExceptionMessageBox.Show("Unable to connect to SQL Server Database - Application start with local database to check configuration", "Information"); } } }
public void LoadInfoFromLocalDb() { try { _db.getSqlServerInfo(out _initialConStr, out _bEnableSql); checkBoxEnableSQL.Checked = _bEnableSql == 1; if (string.IsNullOrEmpty(_initialConStr)) { return; } string[] strArray = _initialConStr.Split(';'); foreach (string str2 in strArray) { if (str2.Length == 0) { break; } string strSwitch = str2.Substring(0, str2.IndexOf('=')).ToUpper().Trim(); switch (strSwitch) { case "DATA SOURCE": txtServerName.Text = str2.Substring(str2.IndexOf('=') + 1); break; case "INITIAL CATALOG": txtDatabaseName.Text = str2.Substring(str2.IndexOf('=') + 1); break; case "USER ID": txtLogin.Text = str2.Substring(str2.IndexOf('=') + 1); break; case "PASSWORD": { string str3 = UtilSqlServer.DencryptPassword(str2.Substring(str2.IndexOf('=') + 1)); txtPassword.Text = str3; break; } } } CboAuthentication.SelectedIndex = txtLogin.Text.Trim().Length > 0 ? 1 : 0; } catch (Exception exception1) { Exception exception = exception1; MessageBox.Show(exception.Message, ResStrings.Str_Key_Not_Found, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } finally { CboAuthentication.SelectedIndex = txtLogin.Text.Trim().Length > 0 ? 1 : 0; } }