用户登陆代码问题
try
{
string myconn= "Integrated Security=SSPI;User Id=sa;database=jindu2;server=localhost ";
SqlConnection myconnection=new SqlConnection (myconn);
myconnection.Open();//打开数据库连接
string usname= "select * from userinfo where username= "+textBox1.Text + " and password= "+textBox2.Text + " ";
SqlCommand cmdd = new SqlCommand(usname, myconnection);
SqlDataReader myreader=cmdd.ExecuteReader();
if(myreader.Read ())
{
Form1 form1=new Form1 ();
form1.Show ();
this.Dispose ();
}
else
MessageBox.Show ( "你输入的密码不正确,请重新输入 ");
myreader.Close ();
myconnection.Close ();
}