<%
dim conn
dim DBOath
dim rs
dim sql
Set conn=Server.CreateObject("ADODB.Connection")
DBPath = Server.MapPath("chinalaserinfo.asp")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
Set rs=Server.CreateObject("ADODB.Recordset")
'从Web页获取值
dim flag
dim gsname
dim cpname
dim fenlei
dim jiage
gsname=request("gsname")
cpname=request("cpname")
fenlei=request("fenlei")
jiage=request("jiage")
gsname=replace(gsname,"*","%")
cpname=replace(cpname,"*","%")
fenlei=replace(fenlei,"*","%")
jiage=replace(jiage,"*","%")
'枚举法的搜索核心,因为有3个条件所以要写8组If判断语句
sql="select * from info where"
if gsname<>"" then
sql=sql&" gsname like '%"&gsname&"%' "
flag=1
end if
if cpname<>"" and flag=1 then
sql=sql&" and cpname like '%"&cpname&"%'"
flag=1
elseif cpname<>"" then
sql=sql&" cpname like '%"&cpname&"%'"
flag=1
end if
if fenlei<>"" and flag=1 then
sql=sql&" and fenlei like '%"&fenlei&"%'"
flag=1
elseif fenlei <>"" then
sql=sql&" fenlei like '%"&fenlei&"%'"
flag=1
end if
if jiage <>"" and flag=1 then
sql=sql&" and jiage like '%"&jiage&"%'"
flag=1
elseif jiage <>"" then
sql=sql&" jiage like '%"&jiage&"%'"
flag=1
end if
if flag=0 then
sql="select * from info order by ID desc"
end if
rs.open sql,conn,1,1
gsname=replace(gsname,"%","*")
cpname=replace(cpname,"%","*")
fenlei=replace(fenlei,"%","*")
jiage=replace(jiage,"%","*")
'显示搜索结果
if not rs.eof then
proCount=rs.recordcount
rs.PageSize=10 '定义显示数目
if not IsEmpty(Request("ToPage")) then
ToPage=CInt(Request("ToPage"))
if ToPage>rs.PageCount then
rs.AbsolutePage=rs.PageCount
intCurPage=rs.PageCount
elseif ToPage<=0 then
rs.AbsolutePage=1
intCurPage=1
else
rs.AbsolutePage=ToPage
intCurPage=ToPage
end if
else
rs.AbsolutePage=1
intCurPage=1
end if
intCurPage=CInt(intCurPage)
For i = 1 to rs.PageSize
if rs.EOF then
Exit For
end if
%>
<TR>
<TD width=20> </TD>
<TD><b><a href="<%=rs("www")%>"><%=rs("gsname")%></a></b> --> (<%=rs("cpname")%>) 所属 [<%=rs("fenlei")%>] </TD>
</TR>
<TR>
<TD> </TD>
<TD><span class="STYLE13">电话: <%=rs("tel")%> | 传真: <%=rs("fax")%> | E-Mail <%=rs("mail")%> | <a href="?work=edit&id=<%=rs("id")%>">修改</a> | <A HREF="javascript:DoEmpty('?work=del&id=<%=rs("id")%>&ok=ck')">删除</a> | <a href="?work=addcp&id=<%=rs("id")%>">添加</a></span></TD>
</TR>
<TR>
<TD> </TD>
<TD class=formatU> <table width="500" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>应用范围:<%=rs("yingyong")%></td>
</tr>
</table>
<br>
<br>
<span class="STYLE12">
<%if trim(rs("upimg"))<>"" then%>
产品图片: <br><img src="/product/file/s/<%=rs("upimg")%>"><BR>
<%end if%>
</span></TD>
</TR>
<TR>
<TD colspan="2"><hr size="1"></TD>
</TR>
<%
rs.MoveNext
next
%>
<TR>
<TD> </TD>
<TD><table width="760" border="0" align="center">
<tr>
<td> <div align="right"><span style="font-size: 9pt;"> 总共:<font color="#ff0000"><%=rs.PageCount%></font>页, <font color="#ff0000"><%=proCount%></font>条信息, 当前页:<font color="#ff0000"> <%=intCurPage%> </font>
<% if intCurPage<>1 then
%>
|<a href="?ToPage=1">第一页</a>|<a href="?ToPage=<%=intCurPage-1%>">上一页</a>|
<% end if
if intCurPage<>rs.PageCount then %>
<a href="?ToPage=<%=intCurPage+1%>">下一页</a>|<a href="?ToPage=<%=rs.PageCount%>"> 最后页</a>|
<% end if%>
转到第
<select name="sel_page" onchange="javascript:location=this.options[this.selectedIndex].value;">
<%
for i = 1 to RS.PageCount
if i = intpage then%>
<option value="?ToPage=<%=i%>" selected><%=i%></option>
<%else%>
<option value="?ToPage=<%=i%>"><%=i%></option>
<%
end if
next
%>
</select>
页
</span></div></TD>
</TR>
</TABLE>
<%
else
%>
<TABLE width="80%" align="center">
<TR>
<TD>对不起!目前库中没有您要查询的记录!</TD>
</TR>
</TABLE>
<%
end if
rs.close
set rs=nothing
%></td>
</tr>
</table>
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E21)
ODBC 驱动程序不支持所需的属性。
/product/product_search.asp, 第 105 行
105行 rs.open sql,conn,1,1
将 < 改成 like 即正常,我想要搜索这个价钱以内的产品
另,当点击下一页出后显示所有产品,请问怎么将搜索的值给予每一页
[此贴子已经被作者于2006-7-1 15:26:03编辑过]