asp对数据库的操作问题

forever_forget 2004-08-11 10:17:37
我想在页面上显示所有的记录,然后可以随时对这些记录修改,删除,添加,
怎么可以让页面显示的内容和库中的内容建立一种联系呢,使页面的内容变化
库中的内容也随之变化呢?
希望大家多多帮忙!不胜感激!!!
...全文
46 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
wzhnet 2004-08-11
提交-处理--ok--返回本页
|
err
|
err页
回复
fashchina 2004-08-11
<%@ Language=VBScript %>
<!--#include file="../conn/conn1.asp" -->
<!--#include file="../session1.asp"-->
<html>
<head>
<title>新闻</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../news.css">
<style type="text/css">
<!--
.样式1 {font-size: 12px}
.p9 {
font-size: 9pt;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: none;
}
-->
</style>
</head><%
set rs=server.CreateObject ("Adodb.RecordSet")
rs.Source="select * from news order by update desc"
rs.Open rs.Source,conn,1,1
dim MaxPerPage
MaxPerPage=14
If rs.eof and rs.bof then
response.write "<p align='center'><font color='#ff0000' class='p9'>现在还没有任何的信息!</font></p>"
response.end
End if
dim text,checkpage
text="0123456789"
Rs.PageSize=MaxPerPage
for i=1 to len(request("page"))
checkpage=instr(1,text,mid(request("page"),i,1))
if checkpage=0 then
exit for
end if
next
If checkpage<>0 then
If NOT IsEmpty(request("page")) Then
CurrentPage=Cint(request("page"))
If CurrentPage < 1 Then CurrentPage = 1
If CurrentPage > Rs.PageCount Then CurrentPage = Rs.PageCount
Else
CurrentPage= 1
End If
If not Rs.eof Then Rs.AbsolutePage = CurrentPage end if
Else
CurrentPage=1
End if
%>

<script language="javascript">
function cdel(id,page){
if (confirm("真的要删除此信息吗?"))
window.location.href="del_news.asp?ID="+id+"&page="+page+""}
</script>
<body text="#000000">

<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#000000" height="1"></td>
</tr>
<tr>
<td height="4"></td>
</tr>
<tr>
<td bgcolor="#000000" height="1"></td>
</tr>
<tr>
<td><table width="100%" height="62" border="0" cellpadding="1" cellspacing="0">
<tr align="center" bordercolor="#242424" bordercolordark="#ffffff" bgcolor=efefef>
<td width="14%" height="26" ><span class="p9">作者</span></td>
<td width="15%" bgcolor="efefef" ><span class="p9">来源</span></td>
<td width="43%" bgcolor="efefef" ><span class="p9">标题</span></td>
<td width="15%" ><span class="p9">提交时间</span></td>
<td colspan="2" ><span class="p9">管理</span></td>
</tr><%
if not rs.eof then
i=0
do while not rs.eof
%>
<tr>
<td height="35"><div align="center" class="p9"></div>
<div align="center" class="p9"><%=rs("author") %></div></td>
<td> <div align="center" class="p9"><%=rs("Original") %></div></td>
<td><div align="center" class="p9"><%title=rs("title")
if len(title)>20 then
title=left(title,18)&"..."
end if
response.Write title %></div></td>
<td><div align="center" class="p9"><%=rs("update") %></div></td>
<td width="7%"><div align="center" class="p9"><a href="editnews.asp?id=<%=rs("newsid")%>&page=<%=currentPage%>">修改</a></div></td>
<td width="6%"><div align="center" class="p9"><a href="javascript:cdel('<%=rs("newsID")%>','<%=currentPage%>')" title="删除信息">删除</a></div></td>
</tr>

<%
i=i+1
if i >= MaxPerpage then exit do
rs.movenext
loop
end if
%> </table> </td>
</tr>
<tr>
<td><div align="right">
<%
call showpages%>
</div></td>
</tr>
</table>
</body>
</html>
<%
sub showpages()%>
<table border="0" cellPadding="0" cellSpacing="0" width="100%">
<tr><td width="695">
<%
response.write "<form method=Post action='news.asp'>"
%>

<table bgColor="#EFEFEF" border="0" cellPadding="0" cellSpacing="0" width="100%" height="30">
<tr>
<td bgcolor="#EFEFEF" >
<font color="#000000" class="p9">
<p align="center">
<%
Response.write "<font color='#000000'>分页-</font>"
If currentpage > 1 Then
response.write "<a href='news.asp?&page="+cstr(1)+"'><font color='#000000'>首页</font></a><font color='#000000'><b>-</b></font>"
Response.write "<a href='news.asp?page="+Cstr(currentpage-1)+"'><font color='#000000'>前页</font></a><font color='#000000'><b>-</b></font>"
Else
Response.write "<font color='#000000'>首页-</font>"
Response.write "<font color='#000000'>前页-</font>"
End if

If currentpage < Rs.PageCount Then
Response.write "<a href='news.asp?page="+Cstr(currentPage+1)+"'><font color='#000000'>后页</font></a><font color='#000000'><b>-</b></font>"
Response.write "<a href='news.asp?page="+Cstr(Rs.PageCount)+"'><font color='#000000'>尾页</font></a>  "
Else
Response.write "<font color='#000000'>后页-</font>"
Response.write "<font color='#000000'>尾页</font>  "
End if
Response.write "<font color='#000000'>页次:</font>" & "<font color=#FF0000>" & Cstr(CurrentPage) & "</font>" & "<font color='#000000'>/" & Cstr(rs.pagecount) & "</font> "
Response.write "<font color=#ff0000>" & Cstr(MaxPerPage) & "</font>" & "<font color='#000000'>条信息/页 " & "共</font>" & "<font color=#FF0000>" & Cstr(Rs.RecordCount) & "</font>" & "<font color='#000000'>条</font>  "

response.write "</td><td align='right'>"
response.write "<font color='#000000' class='p9'>转到</font><input type='text' name='page' size=4 maxlength=4 class=smallInput value="¤tpage&"> "
response.write "<input class=buttonface type='submit' value='Go' name='cndok' style='background-color: #BECFF1' class='p9'></span>  "
%>
<%
end sub
rs.close
set rs=nothing
conn.close
set conn=nothing

%>
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2004-08-11 10:17
社区公告
暂无公告