当前位置: 代码迷 >> ASP >> 语句未结束?解决方法
  详细解决方案

语句未结束?解决方法

热度:41   发布时间:2012-03-21 13:33:15.0
语句未结束?
我在程序中有个查询( "按和弦 "),语句为
      set   rs=server.CreateObject( "adodb.recordset ")
      sql=sql& "select   id,name,price1,pic,mark,jiage   from   product   where   1=1   "
      if   he <> " "   then  
        sql=sql& "and   he     like   ' "he " '   "  
      end   if
      sql=sql& "   order   by   adddate   desc   "
        Rs.Open(sql),conn,1,1
        he为读过来的查询值,表中 "和弦 "字段也为he,怎么程序一运行就说 "语句未结束 "
报错行为 "sql=sql& "and   he     like   ' "he " '   "  
        而我去掉判断条件,直接按表中he字段实际存在的值运行语句:
          set   rs=server.CreateObject( "adodb.recordset ")
      sql=sql& "select   id,name,price1,pic,mark,jiage   from   product   where   1=1   "
      'if   he <> " "   then  
        sql=sql& "and   he     like   ' "64和弦 " '   "  
    '   end   if
      sql=sql& "   order   by   adddate   desc   "
        Rs.Open(sql),conn,1,1
也是报语句未结束,请问原因???

------解决方案--------------------
sql=sql & "and he like '% " & he & "% ' "
  相关解决方案