示例#1
0
 private void frm_login_Load(object sender, EventArgs e)
 {
     logger.Info(User_Login.Name + "Run Login");
     txt_user.Focus();
     try
     {
         ConnectDb       Connect = new ConnectDb();
         MySqlConnection con     = Connect.GetCon();
         con.Open();
         con.Close();
         logger.Info("Db correct");
     }
     catch (Exception ex)
     {
         Frm_Config frm = new Frm_Config();
         frm.ShowDialog();
         logger.Error("Error Db incorrect: " + ex);
     }
 }
示例#2
0
        private void CheckConnectionDb()
        {
            ConnectDb       con   = new ConnectDb();
            MySqlConnection mycon = con.GetCon();

            try
            {
                mycon.Open();
            }
            catch
            {
                XtraMessageBox.Show(Properties.Resources.DisconnectDb, "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                if (mycon.State == ConnectionState.Open)
                {
                    mycon.Close();
                    mycon.Dispose();
                }
            }
        }