我用下面的asp代码,在网页上无法显示数据库内容 50
我用下面的asp代码,在网页上无法显示数据库内容具体代码如下:<html><head><metahttp-equiv="Content-Type"content="tex...
我用下面的asp代码,在网页上无法显示数据库内容具体代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>数据库的连接、增删改查</title>
</head>
<body>
<%
db="Database.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "driver={Microsoft Access Driver (*.mdb)};pwd=admin;dbq=" & Server.MapPath(db)
response.write "数据库连接成功!"
Set rs = Server.CreateObject( "ADODB.Recordset" )
sql = "select * from test;"
rs.open sql,conn,1,3
%>
<br/>
表test的内容:
<table border="1">
<tr>
<td>id</td>
<td>username</td>
<td>password</td>
</tr>
<%
if (rs.bof and rs.eof) then
response.write "nodata!"
else
do while not rs.eof
%>
<tr>
<td><%=rs("id")%></td>
<td><%=rs("username")%></td>
<td><%=rs("password")%></td>
</tr>
<%
rs.movenext
loop
end if
%>
</table>
<%
'conn.execute "update test set username='2' where username='a';"
conn.execute "insert into test(username,password) values ('3','a');"
%>
---------插入数据之后--------<br/>
表test的内容:<br/>
<%
Set rs = Server.CreateObject( "ADODB.Recordset" )
sql = "select * from test;"
rs.open sql,conn,1,3
%>
<table border="1">
<tr>
<td>id</td>
<td>username</td>
<td>password</td>
</tr>
<%
if (rs.bof and rs.eof) then
response.write "nodata!"
else
do while not rs.eof
%>
<tr>
<td><%=rs("id")%></td>
<td><%=rs("username")%></td>
<td><%=rs("password")%></td>
</tr>
<%
rs.movenext
loop
end if
%>
</table>
<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</body>
</html> 展开
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>数据库的连接、增删改查</title>
</head>
<body>
<%
db="Database.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "driver={Microsoft Access Driver (*.mdb)};pwd=admin;dbq=" & Server.MapPath(db)
response.write "数据库连接成功!"
Set rs = Server.CreateObject( "ADODB.Recordset" )
sql = "select * from test;"
rs.open sql,conn,1,3
%>
<br/>
表test的内容:
<table border="1">
<tr>
<td>id</td>
<td>username</td>
<td>password</td>
</tr>
<%
if (rs.bof and rs.eof) then
response.write "nodata!"
else
do while not rs.eof
%>
<tr>
<td><%=rs("id")%></td>
<td><%=rs("username")%></td>
<td><%=rs("password")%></td>
</tr>
<%
rs.movenext
loop
end if
%>
</table>
<%
'conn.execute "update test set username='2' where username='a';"
conn.execute "insert into test(username,password) values ('3','a');"
%>
---------插入数据之后--------<br/>
表test的内容:<br/>
<%
Set rs = Server.CreateObject( "ADODB.Recordset" )
sql = "select * from test;"
rs.open sql,conn,1,3
%>
<table border="1">
<tr>
<td>id</td>
<td>username</td>
<td>password</td>
</tr>
<%
if (rs.bof and rs.eof) then
response.write "nodata!"
else
do while not rs.eof
%>
<tr>
<td><%=rs("id")%></td>
<td><%=rs("username")%></td>
<td><%=rs("password")%></td>
</tr>
<%
rs.movenext
loop
end if
%>
</table>
<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</body>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询