?????? private void button1_Click(object sender, EventArgs e)??????? {??????????? string uname;??????????? string upwd;
??????????? uname = textBox1.Text.ToString();
??????????? upwd = textBox2.Text;
??????????? int num=1;??????????? int db;??????????? db = getDB(uname, upwd);
??????????? if (num == db)??????????? {??????????????? MessageBox.Show("全部成功", "好");??????????? }??????????? else ??????????? {??????????????? MessageBox.Show("NO", "好");??????????? }
??????? }
??????? public static int getDB(string uname,string upwd) ??????? {??????????? SqlConnection con = new SqlConnection("server=XPSP2USER;uid=sa;pwd=sasa;database=demoDB");
??????????? con.Open();
??????????? string sql = "select * from utable where id='"+uname+"'and pwd='"+upwd+"'";
??????????? SqlCommand com = new SqlCommand(sql,con);???????????
?????????? ??????????? ??????????? MessageBox.Show("數(shù)據(jù)庫連接成功","好的");
?????????? int yz;?????????? try ?????????? {?????????????? yz = Convert.ToInt16(com.ExecuteScalar());????????????? ?????????????? }
?????????? catch(Exception e){?????????????? throw ;??? ?????????????? }
?????????? ??????????? con.Close();
??????????? return yz;??????????? ??????? }
異常錯誤 ,請大俠幫忙瞧瞧
慕碼人8056858
2018-12-07 02:51:48