ASP格式网页显示access数据库内容
我想在数据库里显示网页的内容数据库名woaini表名woaini字段xingming和nianling请问该怎么写?我看了好多基本上都不行还有个参考自己弄出来后只能显示一...
我想在数据库里显示网页的内容 数据库名 woaini 表名woaini 字段xingming 和 nianling
请问该怎么写? 我看了好多 基本上都不行 还有个参考自己弄出来后只能显示一条记录 坐等高手回答 格式ASP 展开
请问该怎么写? 我看了好多 基本上都不行 还有个参考自己弄出来后只能显示一条记录 坐等高手回答 格式ASP 展开
展开全部
asp读取并显示数据库表中的内容:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<%
set conn=server.CreateObject("adodb.connection")
conn.connectionstring="driver={Microsoft Access Driver (*.mdb)};dbq=" & server.MapPath("woaini.mdb")
conn.open
%>
<body>
<table width="600" border="0" align="center">
<tr>
<th scope="col">姓名</th>
<th scope="col">年龄</th>
</tr>
<%
str="select * from woaini"
set rs=server.CreateObject("adodb.recordset")
rs.open str,conn,1,3
do while not rs.eof
%>
<tr>
<td><%=rs("xingming")%></td>
<td><%=rs("nianling")%></td>
</tr>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
</table>
</body>
</html>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<%
set conn=server.CreateObject("adodb.connection")
conn.connectionstring="driver={Microsoft Access Driver (*.mdb)};dbq=" & server.MapPath("woaini.mdb")
conn.open
%>
<body>
<table width="600" border="0" align="center">
<tr>
<th scope="col">姓名</th>
<th scope="col">年龄</th>
</tr>
<%
str="select * from woaini"
set rs=server.CreateObject("adodb.recordset")
rs.open str,conn,1,3
do while not rs.eof
%>
<tr>
<td><%=rs("xingming")%></td>
<td><%=rs("nianling")%></td>
</tr>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
</table>
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<%
dim conn,db
dim connstr
db="woaini"
on error resume next
connstr="DBQ="+server.mappath(""&db&"")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
if err then
err.clear
else
conn.open connstr
end if
sub CloseConn()
conn.close
set conn=nothing
end sub
%>
<%
set rs=server.createobject("adodb.recordset")
sql="select * from woaini order by id desc"
rs.open sql,conn,1,3
%>
<%
if rs.eof and rs.bof then
response.write("没有数据!")
response.end()
else
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<%
do while not rs.eof
%>
<tr>
<td width="50%" height="25" class="f14">
<%=rs("xingming")%></td>
<td width="50%" class="font_gray"><%=rs("nianling")%></td>
</tr>
<%
rs.movenext
loop
end if
rs.close
set rs = nothing
%>
</table>
dim conn,db
dim connstr
db="woaini"
on error resume next
connstr="DBQ="+server.mappath(""&db&"")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
if err then
err.clear
else
conn.open connstr
end if
sub CloseConn()
conn.close
set conn=nothing
end sub
%>
<%
set rs=server.createobject("adodb.recordset")
sql="select * from woaini order by id desc"
rs.open sql,conn,1,3
%>
<%
if rs.eof and rs.bof then
response.write("没有数据!")
response.end()
else
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<%
do while not rs.eof
%>
<tr>
<td width="50%" height="25" class="f14">
<%=rs("xingming")%></td>
<td width="50%" class="font_gray"><%=rs("nianling")%></td>
</tr>
<%
rs.movenext
loop
end if
rs.close
set rs = nothing
%>
</table>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询