if (textBox1.Text == ""||textBox2.Text=="")
{
MessageBox.Show("用户和密码不能为空!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
string sqlstr = "Data Source=(local);Initial Catalog=Fm;Persist Security Info=True;User ID=sa;Password=";
SqlConnection con = new SqlConnection(sqlstr);
con.Open();
string comstr = "select * from fm_user where username='" +textBox1.Text
+ "'and password='"+textBox2.Text+"'";
SqlCommand com = new SqlCommand(comstr, con);
SqlDataReader dr = com.ExecuteReader();
if (dr.HasRows)
{
Form2 f2 =new Form2();
f2.show();
}
con.Close();