关闭

删除记录中含图片记录的代码

标签: xpstringcmddelete
711人阅读 评论(0) 收藏 举报
分类:

<%
Dim Recordset1__gid
Recordset1__gid = "1"
If (Request.form("id") <> "") Then
  Recordset1__gid = Request.form("id")
End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = conn_STRING
Recordset1.Source = "SELECT *  FROM mypic  WHERE id IN(" + Replace(Recordset1__gid, "'", "''") + ")"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
'** 参数传递判断模块
Dim XP_cmFileDel__ID
If (Request.Form("id") <> "") Then
XP_cmFileDel__ID = Request.Form("id")
Else
Response.Write ("Sorry,所需参数不足,程序自动结束!")
Response.End
End If

'** 删除记录集对应记录信息
CMD_DelSQL = "DELETE FROM mypic  WHERE id IN(" + Replace(XP_cmFileDel__ID, "'", "''") + ")"
Set XP_cmFileDel = Server.CreateObject("ADODB.Command")
XP_cmFileDel.ActiveConnection = conn_STRING
XP_cmFileDel.CommandText = CMD_DelSQL
XP_cmFileDel.CommandTimeout = 0
XP_cmFileDel.CommandType = 1
XP_cmFileDel.Prepared = true
XP_cmFileDel.Execute()
%>
<% dim smsg
smsg="数据删除操作成功!"
 %>
<%
Dim XP_Dirtpath, XP_Filepath
Dim XP_fso, XP_msg
Set XP_fso = CreateObject("Scripting.FileSystemObject")
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
if Recordset1.Fields.Item("pic").Value<>"" then
'** 删除记录对应文件模块 Recordset:Recordset1.g_img
XP_Dirtpath = "../pic/" ' **上传文件目录名
XP_Filepath = Server.Mappath(XP_Dirtpath & Recordset1.Fields.Item("pic").Value) '** 上传文件名及其绝对路径
     If (XP_fso.FileExists(XP_Filepath)) Then
         '** 判断文件是否存在
         'XP_msg = "文件删除操作成功!"
         smsg1=" /n/n图片删除操作成功! "
         XP_fso.DeleteFile(XP_Filepath)
         '** 删除上传文件
     Else
         smsg2=" /n/n图片不存在! /n 删除操作失败! "
         'XP_msg = "文件删除操作失败!"
     End If
'Response.write XP_msg
'** 显示文件删除情况
end if

  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  Recordset1.MoveNext()
Wend
  Response.Write("<script>")
  Response.Write("alert('/n"&smsg&"/n');")
  Response.Write("location='mypic.asp';")
  Response.Write("</script>")

Recordset1.Close()
Set Recordset1 = Nothing
%>

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:47756次
    • 积分:759
    • 等级:
    • 排名:千里之外
    • 原创:27篇
    • 转载:15篇
    • 译文:0篇
    • 评论:2条
    文章分类
    最新评论
    链接