一個登陸程式碼求大神看看哪裡有異常

qq_39686357發表於2017-08-01
  private void buttondenglu_Click(object sender, EventArgs e)
        {
            if (textBox2.Text == "" || textBox1.Text == "")
            {
                MessageBox.Show("賬戶(密碼)不能為空!");
            }
            else
            {
                string zhanghao = textBox2.Text;
                string mima = textBox1.Text;
                int a = 0;
                SqlConnection con = new SqlConnection(shujuku );
                string chaxun = "update zhxx set 登陸記錄=(select 登陸記錄 from zhxx where 賬戶='" + zhanghao + "'and 密碼='" + mima + "')";
                SqlCommand com = new SqlCommand(chaxun, con);
               // try
                //{
                    con.Open();
                    a=com.ExecuteNonQuery();
                    con.Close();
                    if (a == 1)
                    {
                        Form管理 fm = new Form管理();
                        fm.Show();
                        zhanghu = zhanghao;
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("賬號或密碼錯誤!");
                    }
                //}
               // catch
                //{
                 //   MessageBox.Show("伺服器異常,請稍後!");
               // }

相關文章