注册 登录
编程论坛 ASP.NET技术论坛

请教:vs.net连接数据库编程时提示列名无效

lihui_198405 发布于 2008-08-18 14:05, 1361 次点击
请教:下面程序运行的时候提示错误说列名“username无效,userpwd无效”是怎么回事啊?
 string txtusername = Request.QueryString["username"].ToString();
            string txtuserpwd = Request.QueryString["userpwd"].ToString();
            SqlConnection con = new SqlConnection("server=.;database=login;uid=sa;pwd=a;");
            con.Open();
            SqlCommand cmd = new SqlCommand("select count(*) from login where username='" + txtusername + "'and userpwd='" + txtuserpwd + "'", con);
            [bo]int count = Convert.ToInt32(cmd.ExecuteScalar());[/bo]
            if (count > 0)
            {
                Response.Redirect("main.aspx");
            }
            else
            {
                Response.Redirect("loginfail.htm");
            }
红色行为错误提示行
3 回复
#2
yjq19842008-08-20 10:07
你看表的列名是否正确
提示是你要查询的表里不存在username和userpwd列
#3
lihui_1984052008-08-20 10:31
谢谢
#4
bb38522008-08-20 14:38
login改为[login]
1