+ -
当前位置:首页 → 问答吧 → 谁能告诉我这样修改数据什么修改不了了呢?别的页面也是这么写的,够纳闷了!

谁能告诉我这样修改数据什么修改不了了呢?别的页面也是这么写的,够纳闷了!

时间:2011-09-29

来源:互联网

<!-- #include file="conn.asp" -->
  <%
  img_name=request.querystring("img_name")
  if request.querystring("del")="删除" then
'删除表中扫描件的记录
  Set rs = Server.CreateObject("ADODB.Recordset") 
  sql = "select * from htyj where img_name='"&img_name&"'"
  application.lock
  rs.open sql,conn,1,3
  if rs.recordcount =1 then
  rs.Delete
else
response.write "<script>alert('记录有误无法删除!');history.back();</script>"
response.write "<script>window.close();</script>"
response.end
  end if
  rs.close
  application.unlock
  Set rs = nothing
 
  '删除扫描件原件
  path = "\my\htxt\pic\"
  img_name_path = path & img_name
  img_name_path = server.mappath(img_name_path)
  Set fso = Server.CreateObject("Scripting.FileSystemObject")
  If fso.FileExists(img_name_path) Then '判断文件是否存在!
  fso.DeleteFile (img_name_path),true '此处需要服务器支持FSO删除权限!
  end if
response.write "扫描件已删除!"
response.write "<script>alert('删除成功!');window.close();</script>"
end if
%>
<%if request.querystring("xg")="修改" or request.form("Submit")="确 定 提 交" then%>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>合同扫描件修改说明</title>
</head>
 '这段代码为修改的代码  
<%
set rs=server.CreateObject("ADODB.RecordSet")
sql="select * from htyj where img_name='"&img_name&"'"
  rs.open sql,conn,1,3
if request.form("Submit")="确 定 提 交" then
rs("shuoming")=request.form("shuoming")
  rs.update
rs.close
set rs=nothing
response.write "<script>alert('修改成功!');window.close();</script>"
end if
%>
<body>
<center>
<div>
<form name="form1" method="post" action="htyj_xg.asp">
<table>
  <tr align="left"><td><%=img_name%></td></tr>
  <tr align="left"><td>扫描件说明:</td></tr>
  <tr>
  <td><textarea name="shuoming" cols="50" rows="6" id="shuoming"><%=rs("shuoming")%></textarea></td>
  </tr>
  <tr align="center"><td><input name="Submit" type="submit" class="button" value="确 定 提 交" style="width=130px;height=30px;font-size=12px"></td></tr>
 </table>
</form>
</div>
</center>
</body>
</html>
<%
end if
%>
<%
close.conn
set conn=nothing
%>

作者: qjw9004   发布时间: 2011-09-29

你不觉得这样查询出记录集来再删除有点多此一举么?
直接:
HTML code
'  Set rs = Server.CreateObject("ADODB.Recordset")  
  sql = "select * from htyj where img_name='"&img_name&"'"
  'application.lock
  conn.exec(sql)
  'if rs.recordcount =1 then
  'rs.Delete


不就好了嘛@!

作者: qianjin036a   发布时间: 2011-09-30

OH!还写错了!
HTML code
'  Set rs = Server.CreateObject("ADODB.Recordset")  
  sql = "delete from htyj where img_name='"&img_name&"'"
  'application.lock
  conn.exec(sql)
  'if rs.recordcount =1 then
  'rs.Delete


作者: qianjin036a   发布时间: 2011-09-30