if(textBox1.Text=="" || textBox2.Text=="")
{
MessageBox.Show("请输入用户名,密码","用户名/密码输入");
}
else
{
SqlConnection conn=new SqlConnection("workstation id=ZERG1;packet size=4096;integrated security=SSPI;data source=ZERG1;persist security info=False;initial catalog=Northwind");
conn.Open();
string sql="select * from yhid where yhid='"+textBox1.Text+"' and yhpassword='"+textBox2.Text+"'";
SqlCommand com=new SqlCommand(sql,conn);
SqlDataReader sdr=com.ExecuteReader();
if(sdr.Read())
{
Form2 fr2=new Form2();
fr2.Show();
}
else
{
MessageBox.Show("密码错误!请重新输入密码","密码检测信息");
}