第二章问题:小科
发表在ASP.NET图书答疑
2013-08-07
是否精华
是
否
版块置顶:
是
否
{
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["conStr"]);
con.Open();
string strsql="select count(*) from tb_Admin where UserName='" + this.txtUid.Text + "' and SuperAdmin='True'";
SqlCommand com = new SqlCommand(strsql,con);
SqlData da = new SqlData();
SqlDataReader read = da.ExceRead("select * from tb_Admin where UserName='" + this.txtUid.Text + "'");
read.Read();
if (read.HasRows)
{
Session["SuperAdmin"] = read["SuperAdmin"].ToString();
}
read.Close();
int count = Convert.ToInt32(com.ExecuteScalar());
if (count > 0)
{
if(object.Equals(Request.Cookies["UserName"],null))
{
CreateCookie();
}
else
{
CreateCookie();
}
Session["UserName"] = this.txtUid.Text;
Session["PassWord"] = this.txtPwd.Text;
Page.Response.Redirect("ST_BlogIndex.aspx");
}
else
{
Response.Write("<script lanuage=javascript>alert('用户名或密码有误!');location='javascript:history.go(-1)'</script>");
return;
}
}
你的回答两次是:您好,把if(read.HasRows)和下面的else中间的那段代码放到if(read.HasRows)这个语句块里面。
你运行一下,直接就运行不了。让大家都看一下,简直就是胡说!
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["conStr"]);
con.Open();
string strsql="select count(*) from tb_Admin where UserName='" + this.txtUid.Text + "' and SuperAdmin='True'";
SqlCommand com = new SqlCommand(strsql,con);
SqlData da = new SqlData();
SqlDataReader read = da.ExceRead("select * from tb_Admin where UserName='" + this.txtUid.Text + "'");
read.Read();
if (read.HasRows)
{
Session["SuperAdmin"] = read["SuperAdmin"].ToString();
}
read.Close();
int count = Convert.ToInt32(com.ExecuteScalar());
if (count > 0)
{
if(object.Equals(Request.Cookies["UserName"],null))
{
CreateCookie();
}
else
{
CreateCookie();
}
Session["UserName"] = this.txtUid.Text;
Session["PassWord"] = this.txtPwd.Text;
Page.Response.Redirect("ST_BlogIndex.aspx");
}
else
{
Response.Write("<script lanuage=javascript>alert('用户名或密码有误!');location='javascript:history.go(-1)'</script>");
return;
}
}
你的回答两次是:您好,把if(read.HasRows)和下面的else中间的那段代码放到if(read.HasRows)这个语句块里面。
你运行一下,直接就运行不了。让大家都看一下,简直就是胡说!