| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2101 人关注过本帖
标题:修改代码的错误在哪里????
只看楼主 加入收藏
peiyanjian
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2008-2-29
收藏
 问题点数:0 回复次数:13 
修改代码的错误在哪里????
点击修改之后页面就没反映了.地址显示转到了处理页面了....


这[color=Blue][bo][un]是调出数据的页面.....[/[/un][/bo]color]
update_stu_xx.asp
<%
set conn=server.createobject("adodb.connection")
DSNtemp = "Driver={Microsoft Access Driver (*.mdb)};"
DSNtemp = DSNtemp & "DBQ=" & server.mappath("/swd/date/student.mdb")
conn.open DSNtemp
xuehao = request.querystring("id")
stext = "select * from stu where id=" &xuehao
set rs = conn.execute(stext)
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>个人情况</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>?</p>
<div align="center">
  <table width="100%" border="1" cellpadding="0" cellspacing="0" bgcolor="#82BEF6">
    <!--DWLayoutTable-->
    <tr>
      <td height="50"  colspan="2"  valign="top"><div align="center"><strong><font color="#000000" size="7" face="方正舒体, 方正姚体, ">个人情况登记表</font></strong></div></td>
    </tr>
    <tr>
      <td width="2" height="4"></td>
      <td width="985"></td>
    </tr>
    <tr>
      <td height="295"></td>
      <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
          <!--DWLayoutTable-->
          <form id="form1" name="form1" method="post" action="update_stu_xx_save.asp?id=<%=rs("id") %>">
          <tr>
            <td width="518" height="227" valign="top"><table width="100%" border="1" cellpadding="0" cellspacing="0">
                <!--DWLayoutTable-->
                <tr>
                  <td width="100" height="21">
<div align="center"><strong>姓名</strong></div></td>
                  <td width="105" ><div align="center">
                     <input type="text" name="xingming" size="15" value="<%=(RS.Fields.Item("xingming").Value)%>">
                    </div></td>
                  <td width="190"><div align="center"><strong>担任职务</strong></div></td>
                  <td colspan="3" valign="top" ><div align="center">
                      <input type="text" name="zhiwu" size="15" value="<%=(RS.Fields.Item("zhiwu").Value)%>">
                    </div></td>
                </tr>
                <tr>
                  <td height="20"> <div align="center"><strong>出生年月</strong></div></td>
                  <td><div align="center">
                       <input type="text" name="chushengnianyue" size="15" value="<%=(RS.Fields.Item("chushengnianyue").Value)%>">
                    </div></td>
                  <td><div align="center"><strong>入伍时间</strong> </div></td>
                  <td width="105" ><div align="center">
                       <input type="text" name="ruwushijian" size="15" value="<%=(RS.Fields.Item("ruwushijian").Value)%>">
                    </div></td>
                  <td width="100" ><div align="center"><strong>政治面貌</strong> </div></td>
                  <td width="111" ><div align="center">
                       <input type="text" name="zhengzhimianmao" size="15" value="<%=(RS.Fields.Item("zhengzhimianmao").Value)%>">
                    </div></td>
                <tr>
                  <td height="20"><div align="center"><strong>民族</strong></div></td>
                  <td ><div align="center">
                       <input type="text" name="minzu" size="15" value="<%=(RS.Fields.Item("minzu").Value)%>">
                    </div></td>
                  <td ><div align="center"><strong>入伍地区</strong> </div></td>
                  <td ><div align="center">
                       <input type="text" name="ruwudiqu" size="15" value="<%=(RS.Fields.Item("ruwudiqu").Value)%>">
                    </div></td>
                  <td ><div align="center"><strong>党团时间</strong> </div></td>
                  <td ><div align="center">
                     <input type="text" name="dangtuanshijian" size="15" value="<%=(RS.Fields.Item("dangtuanshijian").Value)%>">
                    </div></td>
                <tr>
                  <td height="25" valign="top"><div align="center"><strong>文化程度</strong></div></td>
                  <td><div align="center">
                       <input type="text" name="wenhuachengdu" size="15" value="<%=(RS.Fields.Item("wenhuachengdu").Value)%>">
                    </div></td>
                  <td ><div align="center"><strong>籍贯</strong> </div></td>
                  <td ><div align="center">
                       <input type="text" name="jiguan" size="15" value="<%=(RS.Fields.Item("jiguan").Value)%>">
                    </div></td>
                  <td ><div align="center"><strong>邮政编码</strong> </div></td>
                  <td ><div align="center">
                       <input type="text" name="youzhengbianma" size="15" value="<%=(RS.Fields.Item("youzhengbianma").Value)%>">
                    </div></td>
                <tr>
                  <td height="20"><div align="center"><strong>班级</strong></div></td>
                  <td><div align="center">
                       <input type="text" name="banji" size="15" value="<%=(RS.Fields.Item("banji").Value)%>">
                    </div></td>
                  <td ><div align="center"><strong>学号</strong> </div></td>
                  <td ><div align="center">
<input type="text" name="xuehao" size="15" value="<%=(RS.Fields.Item("xuehao").Value)%>">
                    </div></td>
                  <td><div align="center"><strong>电话号码</strong> </div></td>
                  <td ><div align="center">
                       <input type="text" name="lianxidianhua" size="15" value="<%=(RS.Fields.Item("lianxidianhua").Value)%>">
                    </div></td>
                <tr>
                  <td height="20"> <div align="center"><strong>家庭住址</strong></div></td>
                  <td colspan="5" valign="top" ><div align="center">
                       <input type="text" name="jiatingzhuzhi" size="60" value="<%=(RS.Fields.Item("jiatingzhuzhi").Value)%>">
                    </div></td>
                <tr>
                  <td height="20"><div align="center"><strong>学习情况</strong></div></td>
                  <td colspan="5" valign="top" ><div align="center">
                       <input type="text" name="xuexiqingkuang" size="60" value="<%=(RS.Fields.Item("xuexiqingkuang").Value)%>">
                    </div></td>
                <tr>
                  <td height="20"><div align="center"><strong>个人奖励</strong></div></td>
                  <td colspan="5" valign="top" ><div align="center">
                     <input type="text" name="gerenjiangli" size="60" value="<%=(RS.Fields.Item("gerenjiangli").Value)%>">
                    </div></td>
                <tr>
                  <td height="20"><div align="center"><strong>违纪情况</strong></div></td>
                  <td colspan="5" valign="top" ><div align="center">
                       <input type="text" name="weijiqingkuang" size="60" value="<%=(RS.Fields.Item("weijiqingkuang").Value)%>">
                    </div></td>
                <tr>
                  <td height="20"><div align="center"><strong>个人评定</strong></div></td>
                  <td colspan="5" valign="top" ><div align="center">
                      <input type="text" name="gerenpingding" size="60" value="<%=(RS.Fields.Item("gerenpingding").Value)%>">
                    </div></td>
                <tr>
                  <td height="20"><div align="center"><strong>支部评定</strong></div></td>
                  <td colspan="5" valign="top" ><div align="center">
                      <input type="text" name="zhibupingding" size="60" value="<%=(RS.Fields.Item("zhibupingding").Value)%>">
                    </div></td>
              </table></td>
            <td width="448" border="1" rowspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                <!--DWLayoutTable-->
                <tr>
                  <td width="447" border="1" height="264" valign="top" >
                    <%if rs("zhaopian")<>"" then%>
                    <p><a href="<%=rs("zhaopian")%>" target="_blank">
                      <%end if%>
                      <img src="<%if rs("zhaopian")="" then%>images/tupian.gif<%end if%><%if rs("zhaopian")<>"" then%><%=rs("zhaopian")%><%end if%>" name="img" width="443" height="277" border="0" id="img" />
                    </a> </p>
                    </td>
                </tr>
                <tr><td><input type="button" name="Submit232" value="相片上传" onClick="javascript:window.open('upload123.asp','窗口名称', 'height=300,width=500,status=no,toolbar=no,menubar=no,location=no,scrollbars=no');" style="width:60;background-color: #FFCC66; color: #000000; border: 1 solid #000000" class="button" /></td></tr>
        </table></td>
          </tr>
          <tr>
            <td height="37"><div align="center">
               
                  <input type="submit" name="Submit" value="修改">
               
              </div></td>
            <td></td>
          </tr></form>
          <tr>
            <td height="20"></td>
            <td></td>
            <td></td>
          </tr>
        </table></td>
      </tr>
  </table>
</div>
</body>
</html>

[color=Blue][bo][un]这是处理修改数据的页面.[/[/un][/bo]color]
update_stu_xx_save.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn_fj16.asp" -->
<!--#include file="admin_qx.asp" -->
<% issjcz %>
<%
if request("action")="edit" then
xingming=trim(request("xingming"))
xuehao=trim(request("xuehao"))
zhiwu=trim(request("zhiwu"))
banji=trim(request("banji"))
chushengnianyue=trim(request("chushengnianyue"))'-----------
zhaopian=session("filepath")
minzu=trim(request("minzu"))
zhengzhimianmao=trim(request("zhengzhimianmao"))
jiguan=trim(request("jiguan"))
dangtuanshijian=trim(request("dangtuanshijian"))
wenhuachengdu=trim(request("wenhuachengdu"))
ruwudiqu=trim(request("ruwudiqu"))
youzhengbianma=trim(request("youzhengbianma"))
ruwushijian=trim(request("ruwushijian"))
lianxidianhua=trim(request("lianxidianhua"))
jiatingzhuzhi=trim(request("jiatingzhuzhi"))
xuexiqingkuang=trim(request("xuexiqingkuang"))
gerenjiangli=trim(request("gerenjiangli"))
weijiqingkuang=trim(request("weijiqingkuang"))
gerenpingding=trim(request("gerenpingding"))
zhibupingding=trim(request("zhibupingding"))
sql="select * from stu"
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,3
'rs.addnew
rs("xingming")=xingming
rs("xuehao")=xuehao
rs("zhiwu")=zhiwu
rs("banji")=banji
rs("chushengnianyue")=chushengnianyue
rs("zhaopian")=zhaopian
rs("minzu")=minzu
rs("zhengzhimianmao")=zhengzhimianmao
rs("jiguan")=jiguan
rs("dangtuanshijian")=dangtuanshijian
rs("wenhuachengdu")=wenhuachengdu
rs("ruwudiqu")=ruwudiqu
rs("youzhengbianma")=youzhengbianma
rs("ruwushijian")=ruwushijian
rs("lianxidianhua")=lianxidianhua
rs("jiatingzhuzhi")=jiatingzhuzhi
rs("xuexiqingkuang")=xuexiqingkuang
rs("gerenjiangli")=gerenjiangli
rs("weijiqingkuang")=weijiqingkuang
rs("gerenpingding")=gerenpingding
rs("zhibupingding")=zhibupingding
rs.update
response.Write "<script language=javascript>{window.alert('学员记录添加成功!请点击“确定”继续添加   ');window.location.href='xy_add.asp';}</script>"
setrs(rs)
end if
%>

[[it] 本帖最后由 peiyanjian 于 2008-5-21 20:26 编辑 [/it]]
搜索更多相关主题的帖子: quot Microsoft DSNtemp stu conn 
2008-05-21 20:25
multiple1902
Rank: 8Rank: 8
等 级:贵宾
威 望:42
帖 子:4881
专家分:671
注 册:2007-2-9
收藏
得分:0 
一点注释都没有也不说你了,一堆代码往上一放就是你的能耐?

建议你动态跟踪一下
2008-05-21 20:27
peiyanjian
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2008-2-29
收藏
得分:0 
楼上,我是菜鸟一个呀.什么也不会,怎么动态跟踪呀??
2008-05-21 20:37
multiple1902
Rank: 8Rank: 8
等 级:贵宾
威 望:42
帖 子:4881
专家分:671
注 册:2007-2-9
收藏
得分:0 
if request("action")="edit" then

你第一个页面有没有写入这个内容为edit的action信息?
2008-05-21 20:42
peiyanjian
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2008-2-29
收藏
得分:0 
恩.怎么修改一下呢??
2008-05-21 20:43
peiyanjian
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2008-2-29
收藏
得分:0 
if request("action")="edit" then
把这句删了.问题解决了.可是出现了新情况呀.修改之后都保存在第一行数据里面了.
也就是不管修改那个ID的数据,结果是把这个页面调出来的数据全部覆盖在了数第一行数据里了........

怎么办呀??
2008-05-21 22:05
hxfly
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:5810
专家分:118
注 册:2005-4-7
收藏
得分:0 
sql="select * from stu"
这句话有没有明确修改的是哪行
加条件判断出你要修改的那行
比如sql="select * from stu &request("id")这样的条件限制

2008-05-21 22:30
hxfly
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:5810
专家分:118
注 册:2005-4-7
收藏
得分:0 
确保你查询到的结果就是你想修改的数据

2008-05-21 22:30
peiyanjian
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2008-2-29
收藏
得分:0 
可是调出来的数据就是我想修改的那行数据呀....
2008-05-21 23:14
hxfly
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:5810
专家分:118
注 册:2005-4-7
收藏
得分:0 
sql="select * from stu"
这句话的执行结果如果就是你想要的执行结果的话,更新的就是SELECT的结果,应该没有错的

你调出来的数据是stext = "select * from stu where id=" &xuehao这个的执行结果。明显和上面的SQL语句不一样

2008-05-21 23:25
快速回复:修改代码的错误在哪里????
数据加载中...
 
   



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

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