首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

登录用户系统有关问题。为什么Red返回总是为0~

2012-04-06 
登录用户系统问题。为什么Red返回总是为0~求救啊C# codeif ((this.usertxt.Text ) || (this.pwdtxt.Te

登录用户系统问题。为什么Red返回总是为0~求救啊

C# code
if ((this.usertxt.Text == "") || (this.pwdtxt.Text == ""))        {            Response.Write("<script>alert('用户名、密码不能为空');</script>");        }        else        {            string ConnectionString = "server=localhost;database=user;uid=sa;pwd=123456";            SqlConnection con = new SqlConnection(ConnectionString);            con.Open();            string name = this.usertxt.Text.ToString();            string pass = this.pwdtxt.Text.ToString();            string cmdtxt = "select * from vip where user='" + name  + "' and pwd ='" + pass + " '";                        SqlCommand cmd = new SqlCommand(cmdtxt, con);            int red = Convert.ToInt32(cmd.ExecuteScalar());            if (red > 0)            {                Session["admin_name"] = this.usertxt.Text.ToString();                Response.Redirect("hello.aspx");            }            else            {                Response.Write("<script>alert('请与管理员联系!');</script>");            }        }


[解决办法]
探讨

引用:

引用:
...and pwd ='" + pass + " '";
看看有什么不同
...and pwd ='" + pass + "'";

不是这问题~我调试运行到SqlCommand cmd = new SqlCommand(cmdtxt, con);的时候,局部变量出现
cmd {System……

[解决办法]
探讨

引用:
引用:

引用:
...and pwd ='" + pass + " '";
看看有什么不同
...and pwd ='" + pass + "'";

不是这问题~我调试运行到SqlCommand cmd = new SqlCommand(cmdtxt, con)……

热点排行