当前位置:编程学习 > C#/ASP.NET >>

在线等,急..查询的代码出错...我是初学者....请各位高手帮忙

 string search = "";

        if (Request.QueryString["ppxx"] != null)
        {
            search += " order31 like '%" + Request.QueryString["ppxx"] + "%' ";
        }

        sqlshow = "select * from orderline where order33='接单'  " + search + " order by id desc";这一句错在哪里................




--------------------编程问答--------------------  search += " And order31 like '%" + Request.QueryString["ppxx"] + "%' ";

--------------------编程问答-------------------- --------------------编程问答--------------------  sqlshow = "select * from orderline where order33='接单' " + search + " order by id desc";


 sqlshow = "select * from orderline where order33='接单' and  " + search + " order by id desc"; --------------------编程问答-------------------- 两个查询条件之间缺少一个and,你可以用search += " And order31 like '%" + Request.QueryString["ppxx"] + "%' ";或则sqlshow = "select * from orderline where order33='接单' and " + search + " order by id desc";两种方式解决
--------------------编程问答-------------------- 果然是初学者。。。。。and..... --------------------编程问答-------------------- 恩  order33='接单' 加个 and  就哦了  --------------------编程问答-------------------- 缺一个and --------------------编程问答-------------------- 两个查询条件之间缺少一个and --------------------编程问答-------------------- 条件之间应该加 and  --------------------编程问答--------------------
引用楼主  的回复:
string search = "";

  if (Request.QueryString["ppxx"] != null)
  {
  search += " order31 like '%" + Request.QueryString["ppxx"] + "%' ";
  }

  sqlshow = "select * from orderline where order33……

注意红色字体部分
sqlshow = "select * from orderline where order33='接单' And" + search + " order by id desc"; --------------------编程问答-------------------- search += " and order31 like '%" + Request.QueryString["ppxx"] + "%' ";
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,