public static void Start_DB_Connection() { try { if (db_con != null) { db_con.Close(); } db_con.ConnectionString = IMS_System.Properties.Settings.Default.DBConnectionString; if (clsCheckConnection.Check_Connection(db_con.DataSource) == true) { db_con.Open(); // MessageBox.Show("opened"); } else { frmDbConnectionLost DB_Connection_Losts = new frmDbConnectionLost(); DB_Connection_Losts.ShowDialog(); } } catch { frmDbConnectionLost DB_Connection_Losts = new frmDbConnectionLost(); DB_Connection_Losts.ShowDialog(); } }
public static void Get_DB_Connection_String() { try { if (File.Exists(Directory.GetCurrentDirectory() + @"\Settings\db_conf\db_con.dll") == true) { Database_conf.Items.Clear(); FileEncrypt.Open_Files(Directory.GetCurrentDirectory() + @"\Settings\db_conf\db_con.dll", ref Database_conf); Database_conf.SetSelected(0, true); Database_conf.SetSelected(1, true); Database_conf.SetSelected(2, true); Database_conf.SetSelected(3, true); dbname = Database_conf.SelectedItems[1].ToString(); dbhost = Database_conf.SelectedItems[0].ToString(); user = Database_conf.SelectedItems[2].ToString(); pass = Database_conf.SelectedItems[3].ToString(); IMS_System.Properties.Settings.Default.DBConnectionString = String.Format("server={0}; user id={1}; password={2}; database={3}; connection timeout=1;", dbhost, user, pass, dbname); // MessageBox.Show("ok"); } else {// Database Error Show frmDbConnectionLost DB_Connection_Losts = new frmDbConnectionLost(); DB_Connection_Losts.ShowDialog(); } } catch { frmDbConnectionLost DB_Connection_Losts = new frmDbConnectionLost(); DB_Connection_Losts.ShowDialog(); } }