select查询问题 (charindex)
protected void Page_Load(object sender, EventArgs e)
{
HttpCookie phonebind = new HttpCookie("phonebind");
if (Request.Cookies["phonebind"] == null)
{
Response.Redirect("../index.aspx");
}
if (Request.QueryString["class"].ToString() == null)
{
Response.Redirect("../index.aspx");
}
string phclass = Request.QueryString["class"];
string phonexh=Request.Cookies["phonebind"].Value;
string sel = "select * from soft where [class]='"+ phclass +"' charindex(" + "'," + phonexh + ",',','+phone+',')>0"; SqlDataSource1.SelectCommand = sel;
SqlDataSource1.DataBind();
}
帮我看下, 这个select哪错了
第 1 行: 'charindex' 附近有语法错误。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.SqlClient.SqlException: 第 1 行: 'charindex' 附近有语法错误。