| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 517 人关注过本帖
标题:[求助]asp+Access为何不能提交修改?
只看楼主 加入收藏
hsqszj
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2006-9-21
收藏
 问题点数:0 回复次数:4 
[求助]asp+Access为何不能提交修改?

asp+Access为何不能提交修改?

问题在于新添加的记录数据可以从页面成功提交修改,

而原有记录的数据却不能通过页面提交修改,为什么?

请大家帮忙分析一下,谢谢!下面是两个代码,看一下那里有问题.

<!-- #include file = "conn.asp" -->
<!--#include file = "chkuser.asp"-->
<%
dim id
id=trim(request("id"))

set rs=server.createobject("adodb.recordset")
sql="select * from st_info where id="& id
rs.open sql,conn,1,1

set rsobj=server.createobject("adodb.recordset")
sql="select * from st_info order by id desc"
rsobj.open sql,conn,1,1
%>

<html>
<head>
<title>班级管理</title>
<meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<link rel = "stylesheet" href = "style.css" type = "text/css">
</head>

<body text = "#000000"><br>
<%if not (rsObj.eof or err) then %>
<form method="POST" action="infomodifysave.asp">
<table width="600" border="1" align="center" cellpadding="5" cellspacing="0" bordercolorlight="#000000" bordercolordark="#FFFFFF">
<tr>
<td width="100%" colspan="2">
<p align="center">修改个人信息</td>
</tr>
<tr>
<td width="37%" align="right">ID编号:</td>
<td width="63%" align="left"><input name="ID" type="text" value="<%=rs("ID")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">姓名:</td>
<td width="63%" align="left"><input name="user_name" type="text" value="<%=rs("user_name")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">性别:</td>
<td width="63%" align="left"><input type="radio" value="男" checked name="user_sex">

<input type="radio" name="user_sex" value="女">
女</td>
</tr>
<tr>
<td width="37%" align="right">民族:</td>
<td width="63%" align="left"><input name="user_idnumber" type="text" value="<%=rs("user_postcode")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">出生年月:</td>
<td width="63%" align="left"><input name="user_testnumber" type="text" value="<%=rs("user_time")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">身份证号:</td>
<td width="63%" align="left"><input name="user_time" type="text" value="<%=rs("user_idnumber")%>" size="40"></td>
</tr>
<tr>
<td width="37%" align="right">文化程度:</td>
<td width="63%" align="left"><input name="user_city" type="text" value="<%=rs("user_area")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">镇村:</td>
<td width="63%" align="left"><input name="user_area" type="text" value="<%=rs("user_city")%>" size="30"></td>
</tr>
<tr>
<td width="37%" align="right">详址(村民小组):</td>
<td width="63%" align="left"><input name="user_address" type="text" value="<%=rs("user_address")%>" size="40"></td>
</tr>
<tr>
<td width="37%" align="right">与户主关系:</td>
<td width="63%" align="left"><input name="user_postcode" type="text" value="<%=rs("user_bedroomphone")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">婚姻状况:</td>
<td width="63%" align="left"><input name="user_homephone" type="text" value="<%=rs("user_major")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">健康状况:</td>
<td width="63%" align="left"><input name="user_bedroomphone" type="text" value="<%=rs("user_testnumber")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">移动电话:</td>
<td width="63%" align="left"><input name="user_mobilephone" type="text" value="<%=rs("user_mobilephone")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">家庭电话:</td>
<td width="63%" align="left"><input name="user_major" type="text" value="<%=rs("user_homephone")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">有何专长:</td>
<td width="63%" align="left"><input name="user_collogetestach" type="text" value="<%=rs("user_collogetestach")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">失地情况:</td>
<td width="63%" align="left"><input name="user_number" type="text" value="<%=rs("user_number")%>" size="30"></td>
</tr>
<tr>
<td width="37%" align="right" valign="top">就业现状及地点:</td>
<td width="63%" align="left"><textarea rows="3" name="user_class" cols="30"><%=rs("user_class")%></textarea></td>
</tr>
<tr>
<td width="37%" align="right" valign="top">培训意向及创业意向:</td>
<td width="63%" align="left"><textarea rows="3" name="user_rp" cols="30"><%=rs("user_rp")%></textarea></td>
</tr>
<tr>
<td width="37%" align="right" valign="top">备注信息:</td>
<td width="63%" align="left"><textarea rows="3" name="user_info" cols="30"><%=rs("user_info")%></textarea></td>
</tr>
<tr>
<td width="100%" colspan="2">
<div align = "center">
<input type = "submit" name = "Submit2" value = "修改">
<input type = "button" name = "Submit3" value = "返回" onClick ="Javascript:window.history.go(-1)">
</div> </tr>
</table>

</form>
<%else %>
您查询的会员资料不存在,请<a href = "Javascript:window.history.go(-1)"> [返回]</a>
</body>
</html>
<%end if

%>






<!-- #include file = "conn.asp" -->
<!-- #include file = "chkuser.asp" -->
<%
dim strSQL, cmdObj, rsObj

Set cmdObj = Server.CreateObject("ADODB.Command")
Set rsObj = Server.CreateObject("ADODB.RecordSet")
cmdObj.CommandText = "SELECT top 1 * FROM st_info ORDER by ID desc"
cmdObj.CommandType = 1
Set cmdObj.ActiveConnection = conn
rsObj.Open cmdObj, , 2,3
rsObj("user_number") = Request.Form("user_number")
rsObj("user_name") = Request.Form("user_name")
rsObj("user_testnumber") = Request.Form("user_testnumber")
rsObj("user_idnumber") = Request.Form("user_idnumber")
rsObj("user_sex") = Request.Form("user_sex")
rsObj("user_time") = Request.Form("user_time")
rsObj("user_city") = Request.Form("user_city")
rsObj("user_area") = Request.Form("user_area")
rsObj("user_address") = Request.Form("user_address")
rsObj("user_postcode") = Request.Form("user_postcode")
rsObj("user_homephone") = Request.Form("user_homephone")
rsObj("user_bedroomphone") = Request.Form("user_bedroomphone")
rsObj("user_mobilephone") = Request.Form("user_mobilephone")
rsObj("user_major") = Request.Form("user_major")
rsObj("user_class") = Request.Form("user_class")
rsObj("user_collogetestach") = Request.Form("user_collogetestach")
rsObj("user_rp") = Request.Form("user_rp")
rsObj("user_info") = Request.Form("user_info")
rsObj.Update
rsObj.Close
set rsObj = nothing
set cmdObj = nothing
' CloseConn()
%>
<script language = Javascript>
<!--
alert("修改成功!");
window.location = "info_manager.asp"
-->
</script>

搜索更多相关主题的帖子: Access asp 
2007-05-24 15:43
utfqqrsf
Rank: 1
等 级:新手上路
帖 子:85
专家分:0
注 册:2005-12-28
收藏
得分:0 
这的确是添加新记录啊~~~~~要修改数据库记录应该用 update 语句吧

2007-05-24 15:50
lq7350684
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:5089
专家分:98
注 册:2006-11-6
收藏
得分:0 
你这两个页面的代码,没有一个是正确的.
2007-05-24 16:36
lq7350684
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:5089
专家分:98
注 册:2006-11-6
收藏
得分:0 

<!-- #include file = "conn.asp" -->
<!--#include file = "chkuser.asp"-->

<html>
<head>
<title>班级管理</title>
<meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<link rel = "stylesheet" href = "style.css" type = "text/css">
</head>

<body>
<%
dim id
id=trim(request("id"))
set rs=server.createobject("adodb.recordset")
sql="select * from st_info where id="&id
rs.open sql,conn,1,1
%>
<form method="POST" action="infomodifysave.asp?id=<%=request("id")%>">
<table width="600" border="1" align="center" cellpadding="5" cellspacing="0" bordercolorlight="#000000" bordercolordark="#FFFFFF">
<tr>
<td width="100%" colspan="2">
<p align="center">修改个人信息</td>
</tr>
<tr>
<td width="37%" align="right">ID编号:</td>
<td width="63%" align="left"><input name="ID" type="text" value="<%=rs("ID")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">姓名:</td>
<td width="63%" align="left"><input name="user_name" type="text" value="<%=rs("user_name")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">性别:</td>
<td width="63%" align="left"><input type="radio" value="男" name="user_sex" <%if rs("user_sex")="男" then response.Write"checked" end if%>>

<input type="radio" name="user_sex" value="女" <%if rs("user_sex")="女" then response.Write"checked" end if%>>
女</td>
</tr>
<tr>
<td width="37%" align="right">民族:</td>
<td width="63%" align="left"><input name="user_postcode" type="text" value="<%=rs("user_postcode")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">出生年月:</td>
<td width="63%" align="left"><input name="user_time" type="text" value="<%=rs("user_time")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">身份证号:</td>
<td width="63%" align="left"><input name="user_idnumber" type="text" value="<%=rs("user_idnumber")%>" size="40"></td>
</tr>
<tr>
<td width="37%" align="right">文化程度:</td>
<td width="63%" align="left"><input name="user_area" type="text" value="<%=rs("user_area")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">镇村:</td>
<td width="63%" align="left"><input name="user_city" type="text" value="<%=rs("user_city")%>" size="30"></td>
</tr>
<tr>
<td width="37%" align="right">详址(村民小组):</td>
<td width="63%" align="left"><input name="user_address" type="text" value="<%=rs("user_address")%>" size="40"></td>
</tr>
<tr>
<td width="37%" align="right">与户主关系:</td>
<td width="63%" align="left"><input name="user_bedroomphone" type="text" value="<%=rs("user_bedroomphone")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">婚姻状况:</td>
<td width="63%" align="left"><input name="user_major" type="text" value="<%=rs("user_major")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">健康状况:</td>
<td width="63%" align="left"><input name="user_testnumber" type="text" value="<%=rs("user_testnumber")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">移动电话:</td>
<td width="63%" align="left"><input name="user_mobilephone" type="text" value="<%=rs("user_mobilephone")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">家庭电话:</td>
<td width="63%" align="left"><input name="user_homephone" type="text" value="<%=rs("user_homephone")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">有何专长:</td>
<td width="63%" align="left"><input name="user_collogetestach" type="text" value="<%=rs("user_collogetestach")%>" size="20"></td>
</tr>
<tr>
<td width="37%" align="right">失地情况:</td>
<td width="63%" align="left"><input name="user_number" type="text" value="<%=rs("user_number")%>" size="30"></td>
</tr>
<tr>
<td width="37%" align="right" valign="top">就业现状及地点:</td>
<td width="63%" align="left"><textarea rows="3" name="user_class" cols="30"><%=rs("user_class")%></textarea></td>
</tr>
<tr>
<td width="37%" align="right" valign="top">培训意向及创业意向:</td>
<td width="63%" align="left"><textarea rows="3" name="user_rp" cols="30"><%=rs("user_rp")%></textarea></td>
</tr>
<tr>
<td width="37%" align="right" valign="top">备注信息:</td>
<td width="63%" align="left"><textarea rows="3" name="user_info" cols="30"><%=rs("user_info")%></textarea></td>
</tr>
<tr>
<td width="100%" colspan="2">
<div align = "center">
<input type = "submit" name = "Submit2" value = "修改">
<input type = "button" name = "Submit3" value = "返回" onClick ="javascript:window.history.go(-1)">
</div> </tr>
</table>
</form>
<%rs.close
set rs=nothing
%>

</body>
</html>
-----------------------------------------------------------------------------------------------
<!-- #include file = "conn.asp" -->
<!-- #include file = "chkuser.asp" -->
<%
Set rs=Server.CreateObject("ADODB.RecordSet")
sql="SELECT * FROM st_info where id="&request("id")
rs.Open sql,conn,1,3
rs("user_number") = Request.Form("user_number")
rs("user_name") = Request.Form("user_name")
rs("user_testnumber") = Request.Form("user_testnumber")
rs("user_idnumber") = Request.Form("user_idnumber")
rs("user_sex") = Request.Form("user_sex")
rs("user_time") = Request.Form("user_time")
rs("user_city") = Request.Form("user_city")
rs("user_area") = Request.Form("user_area")
rs("user_address") = Request.Form("user_address")
rs("user_postcode") = Request.Form("user_postcode")
rs("user_homephone") = Request.Form("user_homephone")
rs("user_bedroomphone") = Request.Form("user_bedroomphone")
rs("user_mobilephone") = Request.Form("user_mobilephone")
rs("user_major") = Request.Form("user_major")
rs("user_class") = Request.Form("user_class")
rs("user_collogetestach") = Request.Form("user_collogetestach")
rs("user_rp") = Request.Form("user_rp")
rs("user_info") = Request.Form("user_info")
rs.Update
rs.Close
set rs=nothing
%>
<script language = Javascript>
<!--
alert("修改成功!");
window.location = "info_manager.asp"
-->
</script>

样子应该是这样的.

2007-05-24 16:51
hsqszj
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2006-9-21
收藏
得分:0 
非常感谢!!!太好了,谢谢lq7350684!!!!
2007-05-24 18:12
快速回复:[求助]asp+Access为何不能提交修改?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023733 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved