生姜有味

     ——program&planar design

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

<%
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
%>

阅读更多
文章标签: xp string cmd delete
个人分类: ASP
想对作者说点什么? 我来说一句

便签(日记本)

2015年07月10日 8KB 下载

vc ado操作数据库实例

2012年05月04日 4.69MB 下载

没有更多推荐了,返回首页

不良信息举报

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

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭