ASP怎样显示数据库里的内容

来源:百度知道 编辑:UC知道 时间:2024/05/18 13:26:49
我刚接触ASP.昨天老师讲课的时候给了一道练习题.
感觉相对ASP编程高手来说比较简单.
练习题目是拿 一个班级里的学生来做例子的。

现在的代码实现了.

添加班级.添加重复班级提示.返回重新添加(连接).

数据库是AC的.
现在. 我想实现.如果在我添加过班级后可以显示. 我原来全部添加过的班级.并且是从后添加的开始显示的..

大家可以参考一下代码..

这个是提交页面.我想实现在提交过后可以显示全部添加班级内容.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>添加班级</title>
</head>

<body>
<form action="add_class_to_mdb.asp" method="post">
<table width="490" border="1" align="center">
<tr>
<td width="117" height="55" nowrap>班级名称:</td>
<td width="357"><input name="classname" type="text" id="classname" size="50" maxlength="50"></td>
</tr>

set rs=server.CreateObject("adodb.recordset") ''''''建立recordset对象
sqlstr="select * from class" '''''test_table为数据库中的一个数据表,即你要显示的数据所存放的数据表
rs.open sqlstr,conn,1,3 '''''表示打开数据库的方式
rs.addnew ''''''新增加一条记录
rs("class_name")=my_bjmc
rs.update
rs.close
set rs=nothing
response.write "<center><font size=10><strong>班级"&my_bjmc&"添加成功!<strong></font></center>"
%>

这后面可以添加
<%
response.rediract("ShowAll.asp")
%>

ShowAll.asp内容主要是
<%
set rs=server.CreateObject("adodb.recordset") ''''''建立recordset对象
sqlstr="select * from class" '''''test_table为数据库中的一个数据表,即你要显示的数据所存放的数据表
rs.open sqlstr,conn,1,3
Do while not Rs.eof
response.w