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

语法错误 (操作符丢失) 在查询表达式 'id=' 中。

asbj 发布于 2009-10-23 17:40, 2329 次点击
Microsoft JET Database Engine 错误 '80040e14'

语法错误 (操作符丢失) 在查询表达式 'id=' 中。

/index.asp,行 987

                  <table width="615" border="0" cellspacing="0" cellpadding="0">
        <tr align="left" valign="top">
          <td width="309" valign="top" height="166" align="left"><table width="300" border="0" cellspacing="0" cellpadding="0" class="xu_kuan">
            <tr>
              <td bgcolor="#fff3b5" width="23" align="center" valign="middle" class="font" height="23"><font color="#FF6600"><img src="images/icon07.gif" width="14" height="13"></font></td>
              <td bgcolor="#fff3b5" width="168" align="left" valign="middle" class="font" height="23"><font color="#FF6600">招工招聘信息推荐</font></td>
              <td bgcolor="#fff3b5" width="118" align="left" valign="middle" class="font" height="23"><img src="images/index_r34_c20.gif" width="108" height="15"></td>
            </tr>
          </table>   
           <%

    strSql="select * from [company] where id=" & request("id")
    set rs=Server.CreateObject("ADODB.RecordSet")
    rs.open strSql,conn,3,3
%>  
          <%
    strSql="select top 5 * from company where type='1' order by id desc"
    set rs=Server.CreateObject("ADODB.RecordSet")
    rs.open strSql,conn,3,3
    %>
    <%do while not rs.eof%>
    <font color="#FF6600">·</font><a href="company/sub_company.asp?id=<%=rs("id")%>&amp;type=1" target="_blank" class="menu"><font color=<%=rs("color")%>><%=left(rs("company"),11)%>&nbsp;<%=rs("tel")%></font></a>
    <%
        rs.movenext
    if not rs.eof then
    response.write "<br>"
    end if
        loop%>
            <table width="299" border="0">
              <tr>
                <td width="293"><div align="right"><img src="images/index_r20_c15.gif" width="131" height="3"><br>
                        <a href="sell1.asp" class="ffbyfont2">更多信息&gt;&gt;&gt;</a></div></td>
              </tr>
            </table></td>
          <td width="306" height="147" align="left" valign="top"><table width="305" border="0" cellspacing="0" cellpadding="0" class="xu_kuan">
            <tr>
              <td bgcolor="#fff3b5" width="23" align="center" valign="middle" class="font" height="23"><font color="#FF6600"><img src="images/icon15.gif" width="12" height="12"></font></td>
              <td bgcolor="#fff3b5" width="168" align="left" valign="middle" class="font" height="23"><font color="#FF6600">供应求购信息推荐</font></td>
              <td bgcolor="#fff3b5" width="118" align="left" valign="middle" class="font" height="23"><img src="images/index_r34_c20.gif" width="108" height="15"></td>
            </tr>
          </table>
           <%

    strSql="select * from [company] where id=" & request("id")
    set rs=Server.CreateObject("ADODB.RecordSet")
    rs.open strSql,conn,3,3
%>
          <%
    strSql="select top 5 * from company where type='2' order by id desc"
    set rs=Server.CreateObject("ADODB.RecordSet")
    rs.open strSql,conn,3,3
    %>
    <%do while not rs.eof%>
    <font color="#FF6600">·</font><a href="company/sub_company.asp?id=<%=rs("id")%>&amp;type=2" target="_blank" class="menu"><font color=<%=rs("color")%>><%=left(rs("company"),11)%>&nbsp;<%=rs("tel")%></font></a>
    <%
        rs.movenext
    if not rs.eof then
    response.write "<br>"
    end if
        loop%>
            <table width="299" border="0">
              <tr>
                <td width="293"><div align="right"><img src="images/index_r20_c15.gif" width="131" height="3"><br>
                        <a href="sell5.asp" class="ffbyfont2">更多信息&gt;&gt;&gt;</a></div></td>
              </tr>
          </table></td>
        </tr>
      </table></td>
              </tr>
            </table></td>
        </tr>
      </table>
      
      <table width="615" border="0" cellspacing="0" cellpadding="0">
        <tr align="left" valign="top">
          <td width="309" valign="top" height="166" align="left">
            <table width="300" border="0" cellspacing="0" cellpadding="0" class="xu_kuan">
              <tr>
                <td bgcolor="#fff3b5" width="23" align="center" valign="middle" class="font" height="23"><font color="#FF6600"><img src="images/icon09.gif" width="14" height="13"></font></td>
                <td bgcolor="#fff3b5" width="168" align="left" valign="middle" class="font" height="23"><font color="#FF6600">装簧装饰信息推荐</font></td>
                <td bgcolor="#fff3b5" width="118" align="left" valign="middle" class="font" height="23"><img src="images/index_r34_c20.gif" width="108" height="15"></td>
              </tr>
            </table>
            <%
    strSql="select top 5 * from company where type='3' order by id desc"
    set rs=Server.CreateObject("ADODB.RecordSet")
    rs.open strSql,conn,3,3
    %>
    <%do while not rs.eof%>
    <font color="#FF6600">·</font><a href="company/sub_company.asp?id=<%=rs("id")%>&amp;type=3" target="_blank" class="menu"><font color=<%=rs("color")%>><%=left(rs("company"),11)%>&nbsp;<%=rs("tel")%></font></a>
    <%
        rs.movenext
    if not rs.eof then
    response.write "<br>"
    end if
        loop%>
            <table width="299" border="0">
              <tr>
                <td width="293"><div align="right"><img src="images/index_r20_c15.gif" width="131" height="3"><br>
                        <a href="sell6.asp" class="ffbyfont2">更多信息&gt;&gt;&gt;</a></div></td>
              </tr>
            </table></td>
          <td width="306" height="147" align="left" valign="top"><table width="305" border="0" cellspacing="0" cellpadding="0" class="xu_kuan">
            <tr>
              <td bgcolor="#fff3b5" width="23" align="center" valign="middle" class="font" height="23"><font color="#FF6600"><img src="images/icon11.gif" width="12" height="12"></font></td>
              <td bgcolor="#fff3b5" width="168" align="left" valign="middle" class="font" height="23"><font color="#FF6600">家政搬家信息推荐</font></td>
              <td bgcolor="#fff3b5" width="118" align="left" valign="middle" class="font" height="23"><img src="images/index_r34_c20.gif" width="108" height="15"></td>
            </tr>
          </table>
          <%
    strSql="select top 5 * from company where type='4' order by id desc"
    set rs=Server.CreateObject("ADODB.RecordSet")
    rs.open strSql,conn,3,3
    %>
    <%do while not rs.eof%>
    <font color="#FF6600">·</font><a href="company/sub_company.asp?id=<%=rs("id")%>&amp;type=4" target="_blank" class="menu"><font color=<%=rs("color")%>><%=left(rs("company"),11)%>&nbsp;<%=rs("tel")%></font></a>
    <%
        rs.movenext
    if not rs.eof then
    response.write "<br>"
    end if
        loop%>
            <table width="299" border="0">
              <tr>
                <td width="293"><div align="right"><img src="images/index_r20_c15.gif" width="131" height="3"><br>
                        <a href="sell7.asp" class="ffbyfont2">更多信息&gt;&gt;&gt;</a></div></td>
              </tr>
          </table></td>
        </tr>
      </table>
4 回复
#2
msgj2009-10-23 18:23
strSql="select * from [company] where id=" & request("id")
把取值加上单引号

strSql="select * from [company] where id='" & request("id") & "'"
#3
chenguoxing5172009-10-23 22:14
<%
 
    strSql="select * from [company] where id=" & request("id")
    set rs=Server.CreateObject("ADODB.RecordSet")
    rs.open strSql,conn,3,3
%>   
          <%
    strSql="select top 5 * from company where type='1' order by id desc"
    set rs=Server.CreateObject("ADODB.RecordSet")
    rs.open strSql,conn,3,3
    %>
建议不要同时使用同一个记录集名称rs,这样在下面进行循环的时候就可能会出现问题,因为你上一个rs都没关闭,又新建一个rs记录集,把这些同名的改下

#4
孤独冷雨2009-10-24 08:03
关不关无所胃,小网站没有问题的,只是他的ID没有获取到值而已!
#5
chenbofeng202009-10-24 09:04
你先查看下id有没有取到
在 strSql="select * from [company] where id=" & request("id")  之后输入以下检查语句
response.writ strSql
response.end()
如果输入结果为select * from [company] where id= 那就是在上一页面没有传

1