private void menuItem2_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());
if(count>0)
{
MessageBox.Show("登陆成功");
frmchoose m=new frmchoose();
m.Show();
this.Close();//
这个没有效果
}
else
{
MessageBox.Show("登陆失败");
thisConnection.Close();
}
}