[求助]我设计的登陆界面有什么错误??
private void btnApply_Click(object sender, System.EventArgs e){
string userid=textUserID.Text.Trim();
string userpassword=textUserPassword.Text.Trim();
if(userid!=""&&userpassword!="")
{
SqlConnection conn=new SqlConnection(str);
SqlCommand thisCommand=new SqlCommand();
thisCommand.Connection=conn;
thisCommand.CommandText="select * from User where UserID='"+userid+"' and UserPassword='"+userpassword+"'";
try
{
conn.Open();
}
catch(Exception ex)
{
MessageBox.Show("数据库连接失败!"+ex);
return;
}
SqlDataReader odr=thisCommand.ExecuteReader();
if(odr.Read())//如果查询记录存在
{
//globeSet=textUserPassword.Text;
MainForm list=new MainForm();
list.ShowDialog();
this.Close();
}
else
{
if(MessageBox.Show("输入的用户名或密码有误,是否重新登录?","输入有误",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)
{
this.textUserID.Clear();
this.textUserPassword.Clear();
}//输入有误,重新输入。
}
odr.Close();
conn.Close();