private void button1_Click(object sender, EventArgs e)
{
string username = textBoxUserName.Text.Trim(); //取出账号
string password = EncryptWithMD5(textBoxPassWord.Text.Trim()); //取出密码并加密
FormMainUser.sno = textBox1.Text.Trim();
//FormCourseUser.Sno = textBox1.Text.Trim();
string myConnString = "Data Source=.;Initial Catalog=School;Persist Security Info=True;User ID=sa;Password=sa";
string sql;
if (comboBox1.Text.Equals("用户"))
{
sql = "select Uname,Upassword from Usertable where Uname = '" + username + "' and Upassword = '" + password + "'";
}
else
{
sql = "select Mid,Mpassword from Managetable where Mname = '" + username + "' and Mpassword = '" + password + "'";
}
SqlConnection sqlConnection = new SqlConnection(myConnString); //实例化连接对象
sqlConnection.Open();
SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection);
想问一下应该怎么解决?账号密码都是对的。