急!!!现在急需一下代码的意思,请各位网友帮忙解释一下。谢谢!

来源:百度知道 编辑:UC知道 时间:2024/05/21 09:36:12
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
string userName = this.TextBoxUserName.Text;
string userPwd = this.TextBoxPassword.Text;
if (userName == "" || userPwd == "")
{
string scriptString = "alert('请输入用户名和密码!’);”;
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "success", scriptString, true);
}
Else
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand comm=new SqlCommand("CustomerLogin",conn);
comm.Parameters.AddWithValue("@strCustomerName",userName);
comm.Parameters.AddWithValue("@strPWD",userPwd);
comm.CommandType=CommandType.StoredProcedure;
SqlDataAdapter adapter=new SqlDataAdapter(comm);
DataSet DBSet=new DataSet();
conn.Open();
adapter.Fill(DBSet);
comm.Dispose();

就是登陆的时候首先要输入登录名和密码
输入了登录名和密码后去数据库里查询有没有这样的用户存在,密码是否正确
如果有这样的用户且密码正确,将它的登录名和密码保存在session里,跳转到tushu.aspx页面。
如果不存在该用户或密码不正确就提示相应的错误信息。

简单的说就是判断用户名文本框和密码文本框的值与连接的数据库里相关字段的值是否一样,如果一样的话登录…如果错误的话提示用户名或密码错误