求教:如何修改数据库的纪录?
cep50 2003-08-09 06:21:07 我要修改数据库的纪录,用 uploadid 字段定位指针,但没次修改都是第一条记录,请帮我解决这一问题. uploadid 字段类型:自动编号
网页一:xgwz0.asp<%@ LANGUAGE="VBSCRIPT"%>
<!--#include file="ADOVBS.INC"-->
<%
if session("first")="" then
page=1
session("first")=1
else
page=request("page")
end if
if page<1 then
page=1
end if
DbPath = SERVER.MapPath("..\data\htgh.mdb")
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DbPath
set rs=server.createobject("adodb.recordset")
sql="select * from upload order by uploaddt desc "
rs.open sql,conn,1
%>
<%
if rs.eof and rs.bof then
response.write "没有图片"
response.write"<br>"
response.write "<a href='javascript:window.history.go(-1)'>返回</a>"
rs.close
conn.close
response.end
end if
rs.pagesize=1
rs.absolutepage=page
%>
<html>
<head>
<title>修改文章</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.botton { font-size: 12px; color: #006600; background-color: #FFFFF8}
.title { font-size: 14px; line-height: 16pt; font-weight: bold; color: #FF6633}
-->
</style>
</head>
<body bgcolor="#FFFFF8">
<div align="center">
<center>
<table width="770" border="0" cellspacing="0" cellpadding="0" height="20" style="border-collapse: collapse" bordercolor="#111111">
<tr align="center" valign="bottom">
<td height="20" class="title" width="770"> 修 改 文 章 </td>
</tr>
</table>
</center>
<%
i=1
While (Not rs.EOF) and (i<=rs.pagesize)
%>
</div>
<form method="post" action="xgwz1.asp" name=frmSend >
<div align="center">
<center>
<table width="770" border="1" cellpadding="0" cellspacing="0" bordercolorlight="#008080" bordercolordark="#008080" style="border-collapse: collapse" bordercolor="#111111" bgcolor="#CCCCFF">
<tr>
<td width="70" align="right">〖标题〗</td>
<td width="700">
<INPUT maxLength=60 name=Title class="botton" size="50" value=<%=rs("Title")%>>
* </td>
</tr>
<tr>
<td width="70" align="right">〖作者〗</td>
<td width="700">
<INPUT maxLength=60 name=username class="botton" size="40" value=<%=rs("username")%>>
</td>
</tr>
<tr>
<td width="70" align="right">〖说明〗</td>
<td width="700">
<textarea cols=108 name=Description rows=3 class="botton"><%=rs("Description")%></textarea></td>
</tr>
</table>
<div><input type='hidden' name='SouceFileName1' value=<%=rs("SouceFileName1")%>></div>
</center>
</div>
<div align="center">
<center>
<table width="770" border="1" cellpadding="0" cellspacing="0" bgcolor="#FFFFCC" height="400" bordercolordark="#008080" bordercolorlight="#008080" style="border-collapse: collapse" bordercolor="#111111">
<tr align="center">
<td width="770"><img height="400" width="600" src="showimage.asp?uploadid=<% =rs("uploadid")%>" <% =rs("data1")%> ></td>
</tr>
</table>
</center>
</div>
<%
rs.MoveNext
i=i+1
Wend
%>
<div align="center">
<center>
<table width="770" border="1" cellpadding="0" cellspacing="0" bordercolorlight="#008080" bordercolordark="#008080" style="border-collapse: collapse" bordercolor="#111111">
<tr>
<td width="770" align="center" bgcolor="#CCCCFF" height="20">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="160" id="AutoNumber2" height="20">
<tr>
<%
if (page>1) then
%>
<td align="center" width="40" height="20"><input type="button" name="Button" value="首页" class="botton" onClick="window.location.href='xgwz0.asp?page=1'"></td>
<td align="center" width="40" height="20"><input type="button" name="Botton" value="前页" class="botton" onClick="window.location.href='xgwz0.asp?page=<%=page-1%>'"></td>
<%
end if
if (cint(page) < rs.pagecount) then
%>
<td align="center" width="40" height="20"><input type="button" name="Botton2" value="下页" class="botton" onClick="window.location.href='xgwz0.asp?page=<%=page+1%>'"></td>
<td align="center" width="40" height="20"><input type="button" name="Botton3" value="末页" class="botton" onClick="window.location.href='xgwz0.asp?page=<%=rs.pagecount%>'"></td>
</tr>
<%
end if
%>
</table>
</td>
</tr>
</table>
</center>
</div>
<div align="center">
<center>
<table width="770" border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
<tr align="right">
<td colspan="2" align="center" height="20">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="160" id="AutoNumber1" height="20">
<tr>
<td width="40" height="20" align="center"> </td>
<td width="40" height="20" align="center">
<input type="Submit" name="Submit" value="修改" class="botton"></td>
<td width="40" height="20" align="center">
<input type="submit" name="Submit2" value="删除" class="botton" ></td>
<td width="40" height="20" align="center"> </td>
</tr>
</table>
</td>
</tr>
<tr align="center">
<td colspan="2" height="20">
</td>
</tr>
<tr>
<td>
<input type="hidden" name="data1" value=<%=rs("data1")%>>
</td>
</tr>
</table>
<% rs.close
conn.close
%>
</center>
</div>
</form>
</body>
</html>
网页二:xgwz1.asp
<%@ LANGUAGE="VBSCRIPT"%>
<%
Title=request("Title")
username=request("username")
Description=request("Description")
uploadid=request("uploadid")
dbpath=server.mappath("..\data\htgh.mdb")
set conn=server.createObject("ADODB.Connection")
conn.open "driver={Microsoft Access Driver (*.mdb)};dbq="&dbpath
set rs=server.createobject("ADODB.Recordset")
rs.open "upload",conn,2,2
sql="select * from upload where uploadid='"&uploadid &"'"
rs("Title")=Title
rs("username")=username
rs("Description")=Description
rs.update
set conn=nothing
%>
<script language=javascript>
<!--
alert("修改成功!");
for(i=0;i<10000;i++);
window.location.href="xgwz0.asp"
//-->
</script>