private void btnDBTest_Click(object sender, EventArgs e) { bool success = DBSettings.TestConnection(txtDBServer.Text.Trim(), txtDBName.Text.Trim(), txtDBUser.Text.Trim(), txtDBPassword.Text.Trim(), chkIntegratedSecurity.Checked); if (success) { MyMessageBox.Show(this, "Database Settings", MyDisplayMessage.TestSuccess); InitializePreferencesTab(); } else { MessageBox.Show("A connection could not be made to the database. Please check your connection information.", "Database Error", MessageBoxButtons.OK); } }
private bool TestConnection() { while (true) { //try //{ if (DBSettings.TestConnection()) { return(true); } else //{ //} //catch (MyException myex) { try { if (DialogResult.No == MessageBox.Show("A connection could not be made to the database. Please check your connection information. Click \"Yes\" to try again or \"No\" to exit.", "Database Error", MessageBoxButtons.YesNo)) { Environment.Exit(0); } frmOptions frm = new frmOptions(); frm.ShowInTaskbar = true; frm.StartPosition = FormStartPosition.CenterScreen; frm.Text = Application.CompanyName + " " + Application.ProductName + " Database Connection"; frm.ShowDialog(); if (frm.IsEmpty()) { return(false); } } catch (ArgumentException) { frmOptions frm = new frmOptions(); frm.ShowInTaskbar = true; frm.StartPosition = FormStartPosition.CenterScreen; frm.Text = Application.CompanyName + " " + Application.ProductName + " Database Connection"; frm.ShowDialog(); if (frm.IsEmpty()) { return(false); } } } } }
private void InitializePreferencesTab() { try { DBSettings.TestConnection(); cbbCounties.DataSource = Helper.IowaCountyList; cbbCounties.DisplayMember = "county"; cbbCounties.ValueMember = "countyid"; cbbCounties.SelectedValue = _user.HomeCountyId; cbxLenientBilling.Checked = _user.LenientBilling; } catch { } }