为什么修改不了原来的数据~~~~~~~~~在线独自等待~~~~~~~~

msq847 2006-07-07 02:01:00
<html>
<head>
<title></title>
</head>
<body>

<%
dim cn,rs,str
set cn=Server.CreateObject("ADODB.Connection")
cn.open="Driver={SQL SERVER};Server=FILESERVER;Database=OA;UID=sa;PWD=kschina918;"
set rs=Server.CreateObject("ADODB.RecordSet")
str = Request.form("sgdwj")
if trim(str)<> "" then
sql = "select * from jlb_ylt where gdwj='"& Request.form("sgdwj") &"'"
else
sql = "select * from jlb_ylt"
end if
rs.open sql,cn,1,1
%>
<br>
<br>
          恭喜,你的记录修改成功:<br>
<p align=center>修改前记录为:</p><br>
<table border=1 align="center">
<tr>
<td width=100 align=center>归档文件</td>
<td width=100 align=center>预期完成日</td>
<td width=100 align=center>实际完成日</td>
<td width=100 align=center>设计人</td>
<td width=100 align=center>审核</td>
<td width=200 align=center>技术备忘</td>
</tr>

<%
if Not rs.Eof then
Do while Not rs.Eof
%>
<tr>
<td width=100 align=center><%=rs(0) %></td>
<td width=100 align=center><%=rs(1) %></td>
<td width=100 align=center><%=rs(2) %></td>
<td width=100 align=center><%=rs(3)%></td>
<td width=100 align=center><%=rs(4)%></td>
<td width=200 align=center><%=rs(5)%></td>
</tr>
<% If not rs.Eof Then rs.MoveNext
Loop
else
%>
<tr>
<td width=100 align=center>无记录</td>
<td width=100 align=center>无记录</td>
<td width=100 align=center>无记录</td>
<td width=100 align=center>无记录</td>
<td width=100 align=center>无记录</td>
<td width=200 align=center>无记录</td>
</tr>
<%end if
rs.close
set rs=nothing
cn.close
set cn=nothing
%>
</table>
<%
dim con,ros
set con=Server.CreateObject("ADODB.Connection")
con.open="Driver={SQL SERVER};Server=FILESERVER;Database=OA;UID=sa;PWD=kschina918;"
set ros=Server.CreateObject("ADODB.RecordSet")
ros.open "select * from jlb_ylt where gdwj='"& Request.form("sgdwj") &"'",con,2,3
%>
<%
ros.addnew //原因好象在这里 这好象是添加 但不知道怎么修改
ros("gdwj")=request.form("sgdwj")
ros("yqwcrq")=request.form("syqwcrq")
ros("sjwcrq")=request.form("ssjwcrq")
ros("sjr")=request.form("ssjr")
ros("sh")=request.form("ssh")
ros("jsbw")=request.form("sjsbw")
ros.update
%>

<%
ros.close
set ros=nothing
con.close
set con=nothing
%>
<p align=center>修改后记录为:</p><br>
<%
dim cbn,rbs
set cbn=Server.CreateObject("ADODB.Connection")
cbn.open="Driver={SQL SERVER};Server=FILESERVER;Database=OA;UID=sa;PWD=kschina918;"
set rbs=Server.CreateObject("ADODB.RecordSet")
rbs.open "select * from jlb_ylt where gdwj='"& Request.form("sgdwj") &"'",cbn,1,1
%>
<table border=1 align="center">
<tr>
<td width=100 align=center>归档文件</td>
<td width=100 align=center>预期完成日</td>
<td width=100 align=center>实际完成日</td>
<td width=100 align=center>设计人</td>
<td width=100 align=center>审核</td>
<td width=200 align=center>技术备忘</td>
</tr>
<%
Do while Not rbs.Eof
%>
<tr>
<td width=100 align=center><%=rbs(0) %></td>
<td width=100 align=center><%=rbs(1) %></td>
<td width=100 align=center><%=rbs(2) %></td>
<td width=100 align=center><%=rbs(3)%></td>
<td width=100 align=center><%=rbs(4)%></td>
<td width=200 align=center><%=rbs(5)%></td>
</tr>
<% If not rbs.Eof Then rbs.MoveNext
Loop
%>
</table>
<%
rbs.close
set rbs=nothing
cbn.close
set cbn=nothing
%>
<br><br><br><br>
<table align=center width=60% color=green>
<tr>
<td align=center><a href="jlb_ylt_edit_ch.asp">返回至信息查询</a></td>
<td align=center><a href="jlb_ylt_edit.asp">返回至主页</a></td>
</tr>
</table>
<br>
<hr width=80% color=green>

</body>
</html>




ros.addnew //原因好象在这里 这好象是添加 但不知道怎么修改

请大家帮我看看

谢谢了
...全文
146 13 打赏 收藏 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
银狐被占用 2006-07-10
  • 打赏
  • 举报
回复
是要更新记录还是要插入啊?
邦迪代驾 2006-07-10
  • 打赏
  • 举报
回复
ros.addnew //原因好象在这里 这好象是添加 但不知道怎么修改
去掉这行
msq847 2006-07-10
  • 打赏
  • 举报
回复
要修改记录
游北亮 2006-07-07
  • 打赏
  • 举报
回复
建议使用Conn.Execute SQL来更新,不推荐直接写。
msq847 2006-07-07
  • 打赏
  • 举报
回复
怎么没有人留下什么话语~~~
msq847 2006-07-07
  • 打赏
  • 举报
回复
那样不行~~~~~~~~~~~~~~~~~~~~~~~
TaoTaoYou 2006-07-07
  • 打赏
  • 举报
回复
Sql="Update table Set 字段='"&修改值&"' where id="&id
Conn.ExeCute(Sql)

这样写试试看行不
msq847 2006-07-07
  • 打赏
  • 举报
回复
9999

我把他改为这样了

<% If not rs.Eof Then rs.MoveNext
Loop
else
%>
<%
response.Write"<script language=JavaScript>" & chr(13) & "alert('修改数据不存在,请重新输入!');"&" history.back();</script>"
response.End
%>
<%end if
rs.close
set rs=nothing
cn.close
set cn=nothing
%>

但是
前面的会先运行显示出来

          恭喜,你的记录修改成功:<br>
<p align=center>修改前记录为:</p><br>

这几句先运行
然后在运行判断那句

怎样修改才能正常运行
msq847 2006-07-07
  • 打赏
  • 举报
回复
改过
但是在修改原来没有的数据是会报错
原因好象是插不进去
因为这是修改
没有给新的数据分配空间
所以插不进去
银狐被占用 2006-07-07
  • 打赏
  • 举报
回复
<%
ros("gdwj").value=request.form("sgdwj")
ros("yqwcrq").value=request.form("syqwcrq")
ros("sjwcrq").value=request.form("ssjwcrq")
ros("sjr").value=request.form("ssjr")
ros("sh").value=request.form("ssh")
ros("jsbw").value=request.form("sjsbw")
ros.update()
%>
银狐被占用 2006-07-07
  • 打赏
  • 举报
回复
去掉那个就更新数据了。
ros.addnew //原因好象在这里 这好象是添加 但不知道怎么修改
这句去掉。
msq847 2006-07-07
  • 打赏
  • 举报
回复
去掉了怎么把修改的数据插到数据库中呢????

showlin 2006-07-07
  • 打赏
  • 举报
回复
不要添加就去掉这行就是

28,402

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧