标题:对数据库修改的问题
只看楼主
chenxingg
Rank: 1
等 级:新手上路
帖 子:94
专家分:0
注 册:2006-1-5
结帖率:0
 问题点数:0 回复次数:14 
对数据库修改的问题
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from [user] where userid="&userid,conn,1,3
if trim(request.form("UserPassword"))<>"" then rs("UserPassword")=md5(trim(request.form("UserPassword")))
rs("realname")=trim(request.form("realname"))
rs("identify")=trim(request.form("identify"))
rs("UserMobile")=trim(request.form("UserMobile"))
rs("userqq")=trim(request.form("userqq"))
rs("MSN")=trim(request.form("MSN"))
rs("useremail")=trim(request.form("useremail"))
rs("UserQuestion")=trim(request.form("UserQuestion"))
if trim(request.form("UserAnswer"))<>"" then rs("UserAnswer")=md5(trim(request.form("UserAnswer")))
rs("UserSex")=request.form("UserSex")
rs("city")=trim(request.form("city"))
rs("address")=trim(request.form("address"))
rs("postcode")=trim(request.form("postcode"))
rs("usertel")=trim(request.form("usertel"))
rs("score")=trim(request.form("score"))
rs("deposit")=trim(request.form("deposit"))
rs("GrpID")=trim(request.form("GrpID"))
rs("book")=trim(request.form("book"))
rs.Update
rs.Close
set rs=nothing
response.Write "<script language=javascript>alert('操作成功!');history.go(-1);</script>"


为什么显示操作成功,但是数据并没有被更改呢?
搜索更多相关主题的帖子: quot form 数据库 trim request 
2007-05-25 10:21
lq7350684
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:5089
专家分:98
注 册:2006-11-6
得分:0 
<%
userid=request("userid")
set rs=server.CreateObject("adodb.recordset")
sql="select * from [user] where userid="&userid
rs.Open sql,conn,1,3
if trim(request.form("UserPassword"))<>"" then
rs("UserPassword")=md5(trim(request.form("UserPassword")))
end if
rs("realname")=trim(request.form("realname"))
rs("identify")=trim(request.form("identify"))
rs("UserMobile")=trim(request.form("UserMobile"))
rs("userqq")=trim(request.form("userqq"))
rs("MSN")=trim(request.form("MSN"))
rs("useremail")=trim(request.form("useremail"))
rs("UserQuestion")=trim(request.form("UserQuestion"))
if trim(request.form("UserAnswer"))<>"" then
rs("UserAnswer")=md5(trim(request.form("UserAnswer")))
end if
rs("UserSex")=request.form("UserSex")
rs("city")=trim(request.form("city"))
rs("address")=trim(request.form("address"))
rs("postcode")=trim(request.form("postcode"))
rs("usertel")=trim(request.form("usertel"))
rs("score")=trim(request.form("score"))
rs("deposit")=trim(request.form("deposit"))
rs("GrpID")=trim(request.form("GrpID"))
rs("book")=trim(request.form("book"))
rs.Update
rs.Close
set rs=nothing
response.Write "<script language=javascript>alert('操作成功!');history.go(-1);</script>"
%>


这样试试.
2007-05-25 10:28
shdyh977
Rank: 1
等 级:新手上路
威 望:1
帖 子:109
专家分:0
注 册:2007-5-22
得分:0 
说明rs.Open "select * from [user] where userid="&userid,conn,1,3没有找到你要找的那条记录,最好你在下边补上一句:
if not rs.eof then
2007-05-25 10:29
gdk2006
Rank: 4
等 级:业余侠客
威 望:8
帖 子:928
专家分:270
注 册:2006-7-2
得分:0 
response.Write "<script language=javascript>alert('操作成功!');history.go(-1);</script>"

我觉得这句啊!你都操作完了还返回去干吗呢!这不是给人误导吗!还因为没有修改好呢!还是写成:
response.Write "<script language=javascript>alert('操作成功!');window.location.href='你要跳转的页面';</script>"

程序员的悲哀如何找女朋友?
追女解决方案百度“让她着迷”!
2007-05-25 15:53
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
得分:0 

楼主用的是什么数据库?

2007-05-25 17:19
chenxingg
Rank: 1
等 级:新手上路
帖 子:94
专家分:0
注 册:2006-1-5
得分:0 
我用的
access的

并且前面还有<%dim userid,rsUser,UserNum
userid=SafeRequest("id",1)
set rs=server.createobject("adodb.recordset")
rs.open "select * from [user] where userid="&userid ,conn,1,1
%>

为什么参数没有传递呢?


淘服网www.
2007-05-28 12:17
chenxingg
Rank: 1
等 级:新手上路
帖 子:94
专家分:0
注 册:2006-1-5
得分:0 

淘服网www.
2007-05-29 09:04
阳光白雪
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:39
帖 子:2220
专家分:0
注 册:2005-11-18
得分:0 
LZ把代码帖全点,给出的这段程序没看出有什么问题,如果文件开头有 on error resume next 等调试时建议注释掉

专注于WEB前端交互平台开发:[url=http://blog./]blog.[/url](富客户端技术(RIA)交流平台)
2007-05-29 09:10
chenxingg
Rank: 1
等 级:新手上路
帖 子:94
专家分:0
注 册:2006-1-5
得分:0 

<form name="form1" method="post" action="saveuser.asp?action=save&id=<%=userid%>">
<td valign="top" bgcolor="#FFFFFF"> <br>
<table width="95%" border="2" align="center" cellpadding="1" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#CCCCCC">
<tr bgcolor="#FFFFFF">
<td width="20%" height="25" align="right" background="images/topbg.gif" bgcolor="#F7F7F7">用户名称:</td>
<td width="80%"><font color=#FF6600><%=trim(rs("username"))%></font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td align="right" background="images/topbg.gif" bgcolor="#F7F7F7">登录密码:</td>
<td>
<input name="UserPassword" type="text" class="input_sr" id="UserPassword" size="30">
不改密码请为空!</td>
............................................................................................

<br>
</td></form>


saveuser.asp



dim userid,action
action=FormatSQL(SafeRequest("action",0))
userid=SafeRequest("id",1)
if userid="" then userid=request.form("userid")
select case action
case "save"
if session("rank")>1 then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('你无权编辑用户信息!');history.go(-1);</script>"
response.End
end if

userid=request("userid")
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from user where userid="&userid,conn,1,3
if trim(request.form("UserPassword"))<>"" then rs("UserPassword")=md5(trim(request.form("UserPassword")))
rs("realname")=trim(request.form("realname"))
...............................................
rs.Update
rs.Close
set rs=nothing
response.Write "<script language=javascript>alert('操作成功!');history.go(-1);</script>"
case "del"
if session("rank")>1 then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('你无权删除用户!');history.go(-1);</script>"
response.End
end if
conn.execute "delete from [user] where userid in ("&userid&") "
conn.execute "delete from orders where userid in ("&userid&")"
response.Redirect "b2b_user.asp"
end select
%>


淘服网www.
2007-05-29 13:40
chenxingg
Rank: 1
等 级:新手上路
帖 子:94
专家分:0
注 册:2006-1-5
得分:0 
问题还没有解决



淘服网www.
2007-05-30 09:28



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-142410-1-1.html




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

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