📄 9.3.1.txt
字号:
protected void Button1_Click(object sender, EventArgs e)
{
//连接数据库
string strConn="server=Localhost;uid=sa;pwd=;database=Aspnet";
string strCmd="select count(*) from Ex09_User where(UserName like'"+TextBox1.Text+"'and Pwd like'"+TextBox2.Text+"')";
SqlConnection myConnection=new SqlConnection();
myConnection.ConnectionString=strConn;
SqlCommand myCommand=new SqlCommand(strCmd,myConnection);
myCommand.Connection.Open();
//检索出的用户数
int flag=(int)myCommand.ExecuteScalar();
myCommand.Connection.Close();
myConnection.Close();
if(flag>0)//用户存在
{
Session["username"]=TextBox1.Text;
Response.Redirect("Ex09_03.aspx");
}
else//用户不存在
{
Label1.Text="对不起!用户名和密码不符,请重新输入.";
TextBox1.Text="";
TextBox2.Text="";
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("Ex09_02.aspx");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -