int userid = Convert.ToInt32(new DBoperate().ExecuteScalar("select Employeeid from Employee where username=" + Session["UserName"]));
int userid=Convert.ToInt32(new DBoperate().ExecuteScalar("select Employeeid from Employee where username='"+Session["UserName"]+"'"));
这两句话的区别是什么, 运行时 提示System.Data.SqlClient.SqlException: 列名 'yuguomin' 无效 yuguomin 是用户名 错误的位置是第一句 哪位帮忙解决下
int userid=Convert.ToInt32(new DBoperate().ExecuteScalar("select Employeeid from Employee where username='"+Session["UserName"]+"'"));
这两句话的区别是什么, 运行时 提示System.Data.SqlClient.SqlException: 列名 'yuguomin' 无效 yuguomin 是用户名 错误的位置是第一句 哪位帮忙解决下
where username=" + Session["UserName"]
上面的语句应该在Session["UserName"]
的 左右两边加上引号。
结果是:
select Employeeid from Employee where username=UserName2. "select Employeeid from Employee where username='"+Session["UserName"]+"'");
结果才是:
select Employeeid from Employee where username=UserName