看看问题所在,谢谢

panda00 2003-10-20 06:39:02
请大家看看这里有没有什么问题:我只是想读出stu.mdb表中的记录并显示的
<%@LANGUAGE="VBSCRIPT" %>
<! --#include file="ADOVBS.INC"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>小测试</title>
</head>

<body>
<% DbPath = server.MapPath("stu.mdb")
whichdsn="driver={Microsoft Access Driver (*.mdb)};dbq=" & DbPath
call querytable("select * from whichdsn",whichdsn)
%>
</body>
<! --#include Virtual ="lib_table.asp"-->
</html>



以下是"lib_table.asp"
<! -- #include file="ADOVBS.INC"-->
<%
sub querytable(inputquery,inputdsn)
dim conntemp,rstemp
set conntemp=server.CreateObject("adodb.connection")
conntemp.open inputdsn
set rstemp=conntemp.execute(inputquery)
howmanyfields=rstemp.fields.count-1
%>
<table border=1 >
<tr>
<%
for i=0 to howmanyfields
%>
<td><b>
<%=rstemp(i).name%>
</b></td>
<%next%>
</tr>
<%
do while not rstemp.eof
%>
<tr>
<%
for i=0 to howmanyfields
thisvalue=rstemp(i)
if isnull(thisvalue)then
thisvalue=" "
end if
%>
<td valign=top><%=thisvalue%></td>
<%
next
%>
</tr>
</table>
<%
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
end sub
%>
...全文
34 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
x0ne 2003-10-20
  • 打赏
  • 举报
回复
這麼簡單的功能,干什麼寫這麼複雜?

用recordset不是很容易麼?

set conntemp=server.CreateObject("adodb.connection")
conntemp.open inputdsn
Set rstemp = Server.CreateObject("ADODB.Recordset")
rstemp.Open inputquery,conntemp

然後用rs("字段名")來訪問數據庫中的字段!
avonqin 2003-10-20
  • 打赏
  • 举报
回复
咩错伽

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧