求winform登录界面的代码 验证!
程序代码:
private void button1_Click(object sender, EventArgs e) { SqlConnection scon = new SqlConnection("server=GATEWAY-DING;database=njdl;uid=sa;pwd=sa"); scon.Open(); DataSet ds = new DataSet(); System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter( "select name,password from nj_user ", scon); da.Fill(ds); if (textBox1.Text.Trim() == "") { MessageBox.Show(null, "用户名不能为空", "登陆失败", MessageBoxButtons.OK, MessageBoxIcon.Question); return; } else if (textBox1.Text.Trim() == ds.Tables[0].Rows[0][0].ToString() && textBox2.Text.Trim() == ds.Tables[0].Rows[0][1].ToString()) { this.DialogResult = DialogResult.OK; } else { MessageBox.Show("用户名或密码不正确"); } }没报错 只是验证不正确 messagebox。show 出来 “用户名或密码不正确 ”
+++++++++++++++ 有经验者 帮我看看啊 无声感谢!!哈哈