C# 新手问题,求解答
登录界面:下面的代码,我不管输入什么数据都是说“密码错误”,就是说始终只执行 else 后的语句,怎么回事啊,在线等答案,谢谢!!!string myconn = "Data Source=8281EDC72ED249A;Initial Catalog=STIS;User ID=sa;Password=;";
SqlConnection myconnection = new SqlConnection(myconn);
myconnection.Open();
string username = textBox1.Text.Trim();
string pwd = textBox2.Text.Trim();
string strSQL = " Select * From ST_User where UserID='" + username + " ' and Password=' " + pwd + " '";
SqlCommand cmd = new SqlCommand(strSQL, myconnection);
SqlDataReader reader = cmd.ExecuteReader();
if (reader.Read())
{
FrmMain main = new FrmMain();
main.ShowDialog();
}
else
MessageBox.Show("用户名或密码错误");
reader.Close();
myconnection.Close();
[此贴子已经被作者于2007-7-16 13:14:50编辑过]