大哥,帮忙看一下

jokeboy 2003-08-25 12:16:00
要实现查询和排序功能,程序没有语法错误,但是不能实现这个功能。


test.asp

<%
'打开数据库
strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("test.mdb")
set conn = server.createobject("adodb.connection")
conn.open strconn
set rs = server.CreateObject("ADODB.Recordset")
sql ="test"
rs.open sql,conn,3,3

%>

<%
Criteria=request("Criteria")
sort=request("sort")
sql= "select * from test"
if Criteria <> "" then
sql= sql & "where" & Criteria
end if
if sort <>"" then
sql= sql & "order by " & sort
end if
%>
<html>
<head>
<title>学生档案管理系统演示程序</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<center>学生档案管理系统演示程序</center>
<hr>

<%
'分页显示
rs.PageSize = 5
Page = CLng(Request("Page")) ' CLng 不可省略
if isnull(page) then Page = 1
If Page < 1 Then Page = 1
If Page > rs.PageCount Then Page = rs.PageCount
rs.AbsolutePage =page

%>
<table width="75%" border="1" align="center">
<tr>
<td>学号</td>
<td>姓名</td>
<td>电话</td>
<td>数学</td>
<td>外语</td>
<td>计算机</td>
</tr>
<% For iPage = 1 To rs.PageSize %>

<tr>

<td><%=rs("学号")%></td>
<td><%=rs("姓名")%></td>
<td><%=rs("电话")%></td>
<td><%=rs("数学")%></td>
<td><%=rs("外语")%></td>
<td><%=rs("计算机")%></td>
</tr>

<% rs.MoveNext
If rs.EOF Then Exit For
Next %>
</table>
<table width="75%" height="21" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="f0f0f0" class="top">
<tr>
<td width="116" height="21"></td>
<td width="176">共计<%=rs.RecordCount%>条 第
<%response.write Page & "/" & rs.PageCount%>
页</td>
<td width="85"><a href=test.asp?Page=<%= Page-1%>>上一页</a></td>
<td width="73"><a href=test.asp?Page=<%= Page+1%>>下一页</a></td>
<td width="134"><a href=test.asp?page=<%= rs.pagecount%>>最后一页</a></td>
</tr>
</table>
<%rs.close%>

<hr align="center">
<p align="center">学生档案查询程序</p>

<form action ="test.asp" method="get">
<table width="75%" height="21" border="1" align="center" cellpadding="0" cellspacing="0" >
<tr>
<td>请输入查询内容:</td>
<td><input type="text" size=20 name="Criteria" value="<%=Criteria%>"></td>
</tr>
<tr>
<td> 请输入排序内容:</td>
<td><input type="text" size=20 name="sort" value="<%=sort%>"></td>
</tr>
<tr>
<td>
<input type="submit" value="提交">
</td>
</tr>
</table>
</body>
</html>
...全文
42 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
82yuxuan 2003-08-25
  • 打赏
  • 举报
回复
呵呵, jokeboy 两边都去呀,一个就是WEBASP,一个就是这里。(我也一样——)
ahuiok 2003-08-25
  • 打赏
  • 举报
回复
<%
'打开数据库
strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("test.mdb")
set conn = server.createobject("adodb.connection")
conn.open strconn
set rs = server.CreateObject("ADODB.Recordset")
sql ="select * from test"
if request("criteria")="" then
criteria=""
else
Criteria=request("Criteria")
end if
if Criteria <> "" then
sql= sql& " where 电话 like '%"&criteria&"%' "
end if
rs.open sql,conn,3,3
if rs.eof or rs.bof then
response.write ("没有数据")
response.end
end if
%>
<html>
<head>
<title>学生档案管理系统演示程序</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<center>学生档案管理系统演示程序</center>
<hr>

<%
'分页显示
rs.PageSize = 5
Page = CLng(Request("Page")) ' CLng 不可省略
if isnull(page) then Page = 1
If Page < 1 Then Page = 1
If Page > rs.PageCount Then Page = rs.PageCount
rs.AbsolutePage =page

%>
<table width="75%" border="1" align="center">
<tr>
<td>学号</td>
<td>姓名</td>
<td>电话</td>
<td>数学</td>
<td>外语</td>
<td>计算机</td>
</tr>
<% For iPage = 1 To rs.PageSize %>

<tr>

<td><%=rs("学号")%></td>
<td><%=rs("姓名")%></td>
<td><%=rs("电话")%></td>
<td><%=rs("数学")%></td>
<td><%=rs("外语")%></td>
<td><%=rs("计算机")%></td>
</tr>

<% rs.MoveNext
If rs.EOF Then Exit For
Next %>
</table>
<table width="75%" height="21" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="f0f0f0" class="top">
<tr>
<td width="116" height="21"></td>
<td width="176">共计<%=rs.RecordCount%>条 第
<%response.write Page & "/" & rs.PageCount%>
页</td>
<td width="85"><a href=test.asp?Page=<%= Page-1%>>上一页</a></td>
<td width="73"><a href=test.asp?Page=<%= Page+1%>>下一页</a></td>
<td width="134"><a href=test.asp?page=<%= rs.pagecount%>>最后一页</a></td>
</tr>
</table>
<%rs.close%>

<hr align="center">
<p align="center">学生档案查询程序</p>

<form action ="test.asp" method="post">
<table width="75%" height="21" border="1" align="center" cellpadding="0" cellspacing="0" >
<tr>
<td>请输入查询内容:</td>
<td><input type="text" size=20 name="Criteria"></td>
</tr>
<tr>
<td> 请输入排序内容:</td>
<td><input type="text" size=20 name="sort"></td>
</tr>
<tr>
<td>
<input type="submit" value="提交">
</td>
</tr>
</table>
</form>
</body>
</html>

页面是这个了,下面的sort 自己做吧。 类似的。

28,390

社区成员

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

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