菜鸟求救!关于ASP查找ACCESS数据表内相符的数据

我想在网页中实现输入产品编号就能查找到相符的记录现有ACCESS数据库,表:product字段名:product_id哪位大哥帮我写一段代码,本人感激不尽啊!... 我想在网页中实现输入产品编号就能查找到相符的记录
现有ACCESS数据库,表:product 字段名:product_id
哪位大哥帮我写一段代码,本人感激不尽啊!
展开
 我来答
百度网友5bc3a83d2
2006-04-19 · TA获得超过417个赞
知道答主
回答量:221
采纳率:100%
帮助的人:0
展开全部
<%
Set rs = Server.CreateObject("ADODB.Recordset")
If lx="不限" then
sql="select * from rsgq where lx like '%"&searchkey&"%' and sh = 1 and yxq >= '"&sj&"' order by jlid desc"
Else
sql="select * from rsgq where lx like '%"&searchkey&"%' and sh = 1 and yxq >= '"&sj&"' and classname = '"&lx&"' order by jlid desc"
End If
rs.open sql,conn,1,1
rs.pagesize=20
tatalrecord=rs.recordcount
tatalpages=rs.pagecount
if rs.recordcount=0 then
response.write "<Script Language=JavaScript>alert('对不起,没有搜索到相关记录!');history.back(-1)</Script>"
response.End
Else
rs.movefirst
nowpage=request("page")
if nowpage&"x"="x" then
nowpage=1
else
nowpage=cint(nowpage)
end if
rs.absolutepage=nowpage
n=1
while not rs.eof and n<=rs.pagesize
%> <tr>
<td height="23" valign="top">
<table width="100%" height="28" border="0" cellpadding="2" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td width="1%" height="26" valign="middle">
<div align="center"><img border="0" src="images/arrow_01.gif"></div></td>
<td width="9%"><font color="#478B47">[<a href="index.asp?lx=<%=trim(rs("classname"))%>" title="查看所有<%=trim(rs("classname"))%>信息"><%=trim(rs("classname"))%></a>]</font></td>
<td width="66%"><font color="#478B47"><a href="read.asp?id=<%=Rs("jlid")%>" title="<%=Trim(Rs("lx"))%>" target="_blank"><%If Len(Rs("lx"))>18 Then%><%=Left(Rs("lx"),18)%><%Else%><%=Trim(Rs("lx"))%><%End If%></a></font></td>
<td width="12%" align="center"><%=rs("hit")%></td>
<td width="12%" align="center"><a href="diqu.asp?dq=<%=Trim(rs("dq"))%>"><%=rs("dq")%></a></td>
</tr>
</table>
<%
url="search.asp?search="&searchkey&"&lx="&lx&"&"
n=n+1
rs.movenext
wend
rs.close
set rs=nothing
%>

这段代码是一段搜索代码,不知道楼主是不是想要这个?总之,如果想搜索某一个字段的话就在where后面加 字段名 like "%变量名%"
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
QD星驰天下
2006-04-25 · 超过37用户采纳过TA的回答
知道小有建树答主
回答量:108
采纳率:0%
帮助的人:89.2万
展开全部
第一步:打开数据库
conn.asp
<%
dim connstr,mysql,myconn
connstr="provider=microsoft.jet.oledb.4.0;data source="& server.mappath("jd.mdb")
set myconn=server.createobject("adodb.connection")
myconn.connectionstring=connstr
myconn.open
%>

第二步:提交查询页面
index.htm
<form method="POST" action="chaxun.asp">
<p>输入产品号:<input type="text" name="T1" size="20">
<input type="submit" value="提交" name="B1"><input type="reset" value="重置" name="B2"></p>
</form>

第三步:显示查询结果
chaxun.asp

<!-- #include file=conn.asp -->
<%

dim cpbh
cpbh=request.form("T1") //接受产品编号

mySQL="select * from product where product_id='" & cpbh& "'"
set myRes=myconn.execute(mySQL)

if myres.bof and myres.eof then //产品编号不存在
response.write"产品编号不存在"
else
%>

<%=product_id %> //产品编号
<%=product_name %> //产品名称
.................
<%end if%>
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式