[Quote=引用 1 楼 chengangmax 的回复:]
if (this.textBox1.Text==""||this.textBox2.Text=="")
{
MessageBox.Show("用户名或密码不能为空","",MessageBoxButtons.OK);
}
//验证用户名和密码
else
{
using (SqlConnection con = new SqlConnection(d.sql……
[/Quote]
if (this.textBox1.Text==""||this.textBox2.Text=="")
{
MessageBox.Show("用户名或密码不能为空","",MessageBoxButtons.OK);
}
//验证用户名和密码
else
{
using (SqlConnection con = new SqlConnection(d.sqlcon()))
{
con.Open();
string sql = "select * from us where UserName='" + textBox1.Text + "' and UserPwd='" + textBox2.Text + "'";
SqlCommand cmd = new SqlCommand(sql, con);
SqlDataReader sdr = cmd.ExecuteReader();
sdr.Read();
if (sdr.HasRows)
{
sdr.Close();
MessageBox.Show("登陆成功", "", MessageBoxButtons.OK);
this.Hide();
main m = new main();
m.Show();