asp网页查询access数据库
需要做一个网页查询防伪码的通过access,数据库名字data.mdb表名DATA字段名:防伪码,在网页上输入防伪码后,如果防伪码在access数据库里面就显示是“正品”...
需要做一个网页查询防伪码的通过access,数据库名字data.mdb 表名DATA 字段名:防伪码,在网页上输入防伪码后,如果防伪码在access数据库里面就显示是“正品”,反之则“假货”。
展开
2015-12-10
展开全部
<%‘连接数据库
db = "md.mdb" '前提时保证数据库文件和本文件在统一目录
connstr = "DBQ=" + server.mappath(""&db&"") + ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
Set conn = server.CreateObject("ADODB.CONNECTION")
conn.Open connstr
set rs = server.CreateObject("adodb.recordset")
'分页函数
sub pcfinal_page(pageMark)'以pageMark作为分页标志
action = "http://" & request.servervariables("http_host") & request.servervariables("script_name")
query = Split(request.servervariables("query_string"), "&")
For Each x in query
a = Split(x, "=")
If StrComp(a(0), pageMark, vbTextCompare) <> 0 Then
temp = temp & a(0) & "=" & a(1) & "&"
End If
Next
response.Write("<div style=""text-align:center;clear:both;""><form method='get' onsubmit=""document.location ='"&action&"?"&temp&pageMark&"='+ this."&pageMark&".value;return false;"">")
If page<= 1 Then
response.Write ("首页 上一页 ")
Else
response.Write("<a href='"&action&"?"&temp&pageMark&"=1'>首页</a> <a href='"&action&"?"&temp&pageMark&"="&(page -1)&"'>上一页</a> ")
End If
If page>= maxpage Then
response.Write ("下一页 尾页 ")
Else
response.Write("<a href='"&action&"?"&temp&pageMark&"="&(page+1)&"'>下一页</a> <a href='"&action&"?"&temp&pageMark&"="&maxpage&"'>尾页</a> ")
End If
response.Write("["&page&"/"&maxpage&"页] [共"&allpage&"条记录] 转到第 <input type='text' name='"&pageMark&"' size='3' value='"&page&"'> 页 <input type='submit' value='跳转'/></form></div>")
end sub
'列出信息
sql = "select * from mingdan order by id"
rs.open sql,conn,1,1
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr class="specialLineCont">
<th>序号</th>
<th>姓名</th>
<th>性别</th>
<th>身份证号码</th>
<th>年龄</th>
</tr>
<%
page = request("page")
If Not IsNumeric(page) Or page = "" Then
page = 1
Else
page = CInt(page)
rs.pagesize = 25
maxpage=rs.pagecount
allpage=rs.Recordcount
End If
If page<1 Then
page = 1
ElseIf page>maxpage Then
page = maxpage
End If
if page = 1 then
specialID = 1
else
specialID = (page-1)*rs.pagesize
end if
rs.AbsolutePage = Page
If page = maxpage Then
x = allpage - (maxpage -1) * iPageSize
Else
x = iPageSize
End If
if rs.eof then
response.Write("暂无内容!")
else
rs.absolutepage = page
for q=1 to rs.pagesize
if not rs.eof then
%>
<tr align="center">
<td><%=rs("ID")%></td>
<td><%=rs("xm")%></td>
<td><%=Rs("xb")%></td>
<td><%=Rs("sfzh")%></td>
<td><%=Rs("nl")%></td>
</tr>
<%Rs.movenext
end if
next%>
</table>
<%
call pcfinal_page("page")
end if
%>
db = "md.mdb" '前提时保证数据库文件和本文件在统一目录
connstr = "DBQ=" + server.mappath(""&db&"") + ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
Set conn = server.CreateObject("ADODB.CONNECTION")
conn.Open connstr
set rs = server.CreateObject("adodb.recordset")
'分页函数
sub pcfinal_page(pageMark)'以pageMark作为分页标志
action = "http://" & request.servervariables("http_host") & request.servervariables("script_name")
query = Split(request.servervariables("query_string"), "&")
For Each x in query
a = Split(x, "=")
If StrComp(a(0), pageMark, vbTextCompare) <> 0 Then
temp = temp & a(0) & "=" & a(1) & "&"
End If
Next
response.Write("<div style=""text-align:center;clear:both;""><form method='get' onsubmit=""document.location ='"&action&"?"&temp&pageMark&"='+ this."&pageMark&".value;return false;"">")
If page<= 1 Then
response.Write ("首页 上一页 ")
Else
response.Write("<a href='"&action&"?"&temp&pageMark&"=1'>首页</a> <a href='"&action&"?"&temp&pageMark&"="&(page -1)&"'>上一页</a> ")
End If
If page>= maxpage Then
response.Write ("下一页 尾页 ")
Else
response.Write("<a href='"&action&"?"&temp&pageMark&"="&(page+1)&"'>下一页</a> <a href='"&action&"?"&temp&pageMark&"="&maxpage&"'>尾页</a> ")
End If
response.Write("["&page&"/"&maxpage&"页] [共"&allpage&"条记录] 转到第 <input type='text' name='"&pageMark&"' size='3' value='"&page&"'> 页 <input type='submit' value='跳转'/></form></div>")
end sub
'列出信息
sql = "select * from mingdan order by id"
rs.open sql,conn,1,1
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr class="specialLineCont">
<th>序号</th>
<th>姓名</th>
<th>性别</th>
<th>身份证号码</th>
<th>年龄</th>
</tr>
<%
page = request("page")
If Not IsNumeric(page) Or page = "" Then
page = 1
Else
page = CInt(page)
rs.pagesize = 25
maxpage=rs.pagecount
allpage=rs.Recordcount
End If
If page<1 Then
page = 1
ElseIf page>maxpage Then
page = maxpage
End If
if page = 1 then
specialID = 1
else
specialID = (page-1)*rs.pagesize
end if
rs.AbsolutePage = Page
If page = maxpage Then
x = allpage - (maxpage -1) * iPageSize
Else
x = iPageSize
End If
if rs.eof then
response.Write("暂无内容!")
else
rs.absolutepage = page
for q=1 to rs.pagesize
if not rs.eof then
%>
<tr align="center">
<td><%=rs("ID")%></td>
<td><%=rs("xm")%></td>
<td><%=Rs("xb")%></td>
<td><%=Rs("sfzh")%></td>
<td><%=Rs("nl")%></td>
</tr>
<%Rs.movenext
end if
next%>
</table>
<%
call pcfinal_page("page")
end if
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询