Beispiel #1
0
        private void Reg_Form_Load(object sender, EventArgs e)
        {
            lab_title.Text = this.Text + " - " + lab_title.Text;
            try
            {
                SQL_Class.getcon();       //连接数据库
            }
            catch
            {
                //当连接数据库失败时,显示错误信息
                MessageBox.Show("数据库连接失败!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();       //关闭窗口
            }
            switch (Form_Type)
            {
            case 0:
                break;

            case 1:
                LoadInfo();
                break;

            case 2:
                break;
            }
        }
 private void Login_Form_Load(object sender, EventArgs e)
 {
     lab_title.Text = this.Text + " - " + lab_title.Text;
     try
     {
         SQL_Class.getcon();       //连接数据库
     }
     catch
     {
         //当连接数据库失败时,显示错误信息
         MessageBox.Show("数据库连接失败!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         Application.Exit();       //关闭整个工程
     }
 }