日期:2014-05-17  浏览次数:21140 次

页面的SQL语句出问题了 求人帮忙看看
VB code

<%
 dim cnstr,epage,i,count,a
     a=request.QueryString("id")
   cnstr = "driver={Microsoft Access Driver (*.mdb)};dbq=" & server.MapPath("./sb.mdb") 
   dim rs
   set cn = server.CreateObject("adodb.connection")
   cn.Open cnstr
   sql = "select * from user,rz where user.U_ID=rz.U_ID and U_ID="&a&" order by R_Time desc"
   set rs = server.createobject("adodb.recordset")
   rs.open sql,cn,3
   If (rs.bof And rs.EOF) Then

else
   rs.pagesize=20
   '设置每页记录数
   if request("page")<>"" then
     epage=cint(request("page"))
   '取当前的页数
   if epage<1 then epage=1
   '若当前页数小于1则置为1
   if epage>rs.pagecount then epage=rs.pagecount
   '若当前页数大于最大页数值则置为最大页数
   else
     epage=1
   '否则页数为默认值1
   end if
   rs.absolutepage=epage
   '记录定位到当前页
   for i=0 to rs.pagesize-1
   '循环显示本页记录
    if rs.bof or rs.eof then exit for 
    '若已经到记录末尾或没有数据则退出循环
    count = count+1
    response.Write "<tr>"
    response.write "<td align='left' width='40%' >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"&rs("U_Xm")&"</td>"
    response.Write "<td align='center' width='40%'>"&rs("R_Time")&"</td>"
    response.write "<td align='center' width='20%'>"&rs("R_Cz")&"</td>"

    response.Write "</tr>"
    rs.movenext
   next   
   end if 
%>
          <tr>
              <td valign="bottom" colspan="3">
                <p align="center">
<br />
<br />
<br />
<a href="grrz.asp?id=<%=id%>&page=1" target="_self">首页</a>&nbsp;
<%if epage > 1  then%>
<a href="grrz.asp?id=<%=id%>&page=<%=epage-1%>" target="_self">前一页</a>&nbsp;
<%
end if
if epage <  rs.pagecount then 
%>
<a href="grrz.asp?id=<%=id%>&page=<%=epage+1%>" target="_self">后一页</a>&nbsp;
<%end if%>
<a href="grrz.asp?id=<%=id%>&page=<%=rs.pagecount%>" target="_self">末页</a></p>
<p align="center" style="vertical-align:bottom">现在是第<%=epage%>页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;一共有<%=rs.pagecount%>页 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;每页20条记录&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;总共有<% =rs.RecordCount %>条记录</p>   
<%
   cn.Close
   set cn = nothing
%>




request.QueryString("id")的值都是数字
我把查询语句改成select * from user,rz where user.U_ID=rz.U_ID and U_ID=5 order by R_Time desc U_ID=5 数据库有符合的值 去数据库查询时候提示 该特定字段'U_ID'可参考SQL语句中from子句表中的多个表

------解决方案--------------------
U_ID重名了。
select * 改成 每个字段
SELECT user.U_ID, user.XXX, user.XXX, rz.XXXX ...