string userid = this.textBox1.Text;
string password = this.textBox2.Text;
if (userid.Equals("") || password.Equals(""))//用户名或密码为空
{
MessageBox.Show("用户名或密码不能为空");
}
else//用户名或密码不为空
{
SqlConnection conn = new SqlConnection("Server=.;Integrated Security=true;Database=YKL");
conn.Open();
SqlCommand cmd = new SqlCommand("select*from boss where BossID='" + userid + "'and PassWord='" + password + "'", conn);
SqlDataReader sdr = cmd.ExecuteReader();
sdr.Read();
if (sdr.HasRows) //从结果中找到
{
MessageBox.Show("登录成功", "提示");
new Form2().Show();
}
else
{
MessageBox.Show("用户名或密码错误", "提示");
return;
}
}
c#登陆的实现
最新推荐文章于 2023-03-27 23:34:36 发布