static void Main()
{
frmLogin login=new frmLogin();
login.ShowDialog();
if(login.IsLogin==true)
Application.Run(new Main());
}
划下划线的那一句运行不下去,高手请指教
static void Main()
{
frmLogin login=new frmLogin();
login.ShowDialog();
if(frmlogin.IsLogin==true)
Application.Run(new Main());
}
private void btnLogin_Click(object sender, System.EventArgs e)
{
if(this.txtUserName.Text=="")
{
MessageBox.Show("请输入用户名!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
if(this.txtPass.Text=="")
{
MessageBox.Show("请输入用户密码!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
SqlConnection thisConnection=new SqlConnection(@"Data Source=(local);Integrated Security=SSPI;"+"Initial Catalog=student");
thisConnection.Open();
SqlCommand cmd=new SqlCommand("select Count(*) from userpass where userid='"+this.txtUserName.Text+"' and Password='"+this.txtPass.Text+"'",thisConnection);
int count=Convert.ToInt32(cmd.ExecuteScalar());
string uid="";
string upwd="";
try
{
thisConnection.Open();
SqlDataReader reader=cmd.ExecuteReader();
if(reader.Read())
{
uid=reader[0].ToString();
upwd=reader[1].ToString();
}
else
{
uid="";
upwd="";
}
reader.Close();
thisConnection.Close();
}
catch(SqlException er)
{
if(thisConnection.State==ConnectionState.Open)
thisConnection.Close();
MessageBox.Show(er.Message,"错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
return;
}
if(uid=="")
{
MessageBox.Show("用户名不存在!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
if(upwd.Trim()!=this.txtPass.Text.Trim())
{
MessageBox.Show("用户密码不正确!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
this.IsLogin=true;
this.Close();
}
}
}
2句下划线的错误