asp多条件查询后分页不对
<%connstr="DBQ="+server.mappath("../vftr/ghjui.mdb")+";DefaultDir=;DRIVER={MicrosoftA...
<%
connstr="DBQ="+server.mappath("../vftr/ghjui.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
Set conn=Server.CreateObject("ADODB.CONNECTION")
conn.open connstr
%>
<%
SeachModel=request.form("SeachModel")
names=Split(SeachModel,", ")
i=0
sql="select * from [csb2] where"
for each name in names
if names(i)="1" then
sql=sql+" and c2='"&c2&"'"
end if
if names(i)="2" then
sql=sql+" and c3 ='"&c3&"'"
end if
if names(i)="3" then
sql=sql+" and c8 like '%"&c8&"%'"
end if
if names(i)="4" then
sql=sql+" and c9 like '%"&c9&"%'"
end if
if names(i)="5" then
sql=sql+" and c11 like '%"&c11&"%'"
end if
if names(i)="6" then
sql=sql+" and c12 like '%"&c12&"%'"
end if
i=i+1
next
sql=sql+" order by c3"
page=clng(request("page"))
set rs=server.createobject("adodb.recordset")
sql=Replace(sql, "where and", "where")
%>
<%
dim i
i=0
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "<tr><td><br><br><center>还没有符合条件的查询!</center><br><br></td></tr>"
else
rs.PageSize=10
if page=0 then page=1
pages=rs.pagecount
if page > pages then page=pages
rs.AbsolutePage=page
for j=1 to rs.PageSize
i=i+1
%>
<TR>
<TD>
<%=rs("id")%></TD>
<TD >
<a href="sbmxck.asp?c1=<%=rs("c1")%>"><%=rs("c1")%></a></TD>
<TD ><%=rs("c2")%> </TD>
<TD ><%=rs("c3")%> </TD>
<TD><%=left(rs("c25"),25)%> </TD>
</TR>
</TBODY>
<%
rs.movenext
if rs.eof then exit for
next
%>
<form method=Post action="gjsearch3.asp">
<td height="30" align="center">
<%if Page<2 then
response.write "首页 上一页 "
else
response.write "<a href=gjsearch3.asp?page=1>首页</a> "
response.write "<a href=gjsearch3.asp?page=" & Page-1 & ">上一页</a> "
end if
if rs.pagecount-page<1 then
response.write "下一页 尾页"
else
response.write "<a href=gjsearch3.asp?page=" & (page+1) & ">"
response.write "下一页</a> <a href=gjsearch3.asp?page="&rs.pagecount&">尾页</a>"
end if
response.write " 页次:<strong><font color=red>"&Page&"</font>/"&rs.pagecount&"</strong>页 "
response.write " 共<b><font color='#FF0000'>"&rs.recordcount&"</font></b>条记录 <b>"&rs.pagesize&"</b>条记录/页"
response.write " 转到:<input type='text' name='page' size=4 maxlength=10 class=input value="&page&">"
response.write " <input class=input type='submit' value=' Goto ' name='cndok'></span></p>"
%>
</td></form>
</tr>
</table>
<%
end if
%>
全部设备列表
id 设备编号 所属车间 类别 备注
Microsoft OLE DB Provider for ODBC Drivers '80040e21'
ODBC 驱动程序不支持所需的属性。
\tc711.com\dzz2\dzz\sbbb\gjsearch3.asp, line 77
第77行的内容是“rs.open sql,conn,1,1”
--------------------------------------------------------------------------------
Host by NetBox Version 2.8 Build 4128 展开
connstr="DBQ="+server.mappath("../vftr/ghjui.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
Set conn=Server.CreateObject("ADODB.CONNECTION")
conn.open connstr
%>
<%
SeachModel=request.form("SeachModel")
names=Split(SeachModel,", ")
i=0
sql="select * from [csb2] where"
for each name in names
if names(i)="1" then
sql=sql+" and c2='"&c2&"'"
end if
if names(i)="2" then
sql=sql+" and c3 ='"&c3&"'"
end if
if names(i)="3" then
sql=sql+" and c8 like '%"&c8&"%'"
end if
if names(i)="4" then
sql=sql+" and c9 like '%"&c9&"%'"
end if
if names(i)="5" then
sql=sql+" and c11 like '%"&c11&"%'"
end if
if names(i)="6" then
sql=sql+" and c12 like '%"&c12&"%'"
end if
i=i+1
next
sql=sql+" order by c3"
page=clng(request("page"))
set rs=server.createobject("adodb.recordset")
sql=Replace(sql, "where and", "where")
%>
<%
dim i
i=0
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "<tr><td><br><br><center>还没有符合条件的查询!</center><br><br></td></tr>"
else
rs.PageSize=10
if page=0 then page=1
pages=rs.pagecount
if page > pages then page=pages
rs.AbsolutePage=page
for j=1 to rs.PageSize
i=i+1
%>
<TR>
<TD>
<%=rs("id")%></TD>
<TD >
<a href="sbmxck.asp?c1=<%=rs("c1")%>"><%=rs("c1")%></a></TD>
<TD ><%=rs("c2")%> </TD>
<TD ><%=rs("c3")%> </TD>
<TD><%=left(rs("c25"),25)%> </TD>
</TR>
</TBODY>
<%
rs.movenext
if rs.eof then exit for
next
%>
<form method=Post action="gjsearch3.asp">
<td height="30" align="center">
<%if Page<2 then
response.write "首页 上一页 "
else
response.write "<a href=gjsearch3.asp?page=1>首页</a> "
response.write "<a href=gjsearch3.asp?page=" & Page-1 & ">上一页</a> "
end if
if rs.pagecount-page<1 then
response.write "下一页 尾页"
else
response.write "<a href=gjsearch3.asp?page=" & (page+1) & ">"
response.write "下一页</a> <a href=gjsearch3.asp?page="&rs.pagecount&">尾页</a>"
end if
response.write " 页次:<strong><font color=red>"&Page&"</font>/"&rs.pagecount&"</strong>页 "
response.write " 共<b><font color='#FF0000'>"&rs.recordcount&"</font></b>条记录 <b>"&rs.pagesize&"</b>条记录/页"
response.write " 转到:<input type='text' name='page' size=4 maxlength=10 class=input value="&page&">"
response.write " <input class=input type='submit' value=' Goto ' name='cndok'></span></p>"
%>
</td></form>
</tr>
</table>
<%
end if
%>
全部设备列表
id 设备编号 所属车间 类别 备注
Microsoft OLE DB Provider for ODBC Drivers '80040e21'
ODBC 驱动程序不支持所需的属性。
\tc711.com\dzz2\dzz\sbbb\gjsearch3.asp, line 77
第77行的内容是“rs.open sql,conn,1,1”
--------------------------------------------------------------------------------
Host by NetBox Version 2.8 Build 4128 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询