asp:如何删除数据库的数据同时并删除图片?
如何删除数据库的数据同时并同时删除文件夹里相应删除图片?我的删除数据的代码如下:myselect=request.Form("myselect")setrs=server...
如何删除数据库的数据同时并同时删除文件夹里相应删除图片?
我的删除数据的代码如下:
myselect=request.Form("myselect")
set rs=server.CreateObject("ADODB.RecordSet")
sql="delete from Product where ProductId In (" &myselect& ")"
conn.Execute(sql)
Response.Write("<script language='javascript'>alert('√你已经删除成功!');window.location.href='Product_Show.asp';</script>")
Response.End()
请各位高手详细的指点一下!给个具体的代码!谢谢!
<%
page=Request("page")
myselect=request.Form("myselect")
getPath4Del(myselect)
set rs=server.CreateObject("ADODB.RecordSet")
sql="delete from Product where ProductId In (" &myselect& ")"
conn.Execute(sql)
%>
<%
Function getPath4Del(myselect)
dim sqlDel,rsDel,path
sqlDel="select productpic from Product where ProductId In (" &myselect& ")"
set rsDel=server.CreateObject("adodb.recordset")
rsDel.open sqlDel,conn,1,1
if not rsDel.eof then
path=rsDel("productpic")
path=replace(path,"../Product","")
path=replace(path,"/","\")
path=server.MapPath("./")&path
'Response.Write(path&"<br>")'--------------需要查看路径是否正确时,取消本行注释。
rsDel.movenext
DeleteAFile(path)
end if
End Function
%>
<%
'DelteAFile(path)
Sub DeleteAFile(path)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile(path)
set fso=nothing
End Sub
%>正确的完整底码应该是这样的~贴出来以供大家参考! 展开
我的删除数据的代码如下:
myselect=request.Form("myselect")
set rs=server.CreateObject("ADODB.RecordSet")
sql="delete from Product where ProductId In (" &myselect& ")"
conn.Execute(sql)
Response.Write("<script language='javascript'>alert('√你已经删除成功!');window.location.href='Product_Show.asp';</script>")
Response.End()
请各位高手详细的指点一下!给个具体的代码!谢谢!
<%
page=Request("page")
myselect=request.Form("myselect")
getPath4Del(myselect)
set rs=server.CreateObject("ADODB.RecordSet")
sql="delete from Product where ProductId In (" &myselect& ")"
conn.Execute(sql)
%>
<%
Function getPath4Del(myselect)
dim sqlDel,rsDel,path
sqlDel="select productpic from Product where ProductId In (" &myselect& ")"
set rsDel=server.CreateObject("adodb.recordset")
rsDel.open sqlDel,conn,1,1
if not rsDel.eof then
path=rsDel("productpic")
path=replace(path,"../Product","")
path=replace(path,"/","\")
path=server.MapPath("./")&path
'Response.Write(path&"<br>")'--------------需要查看路径是否正确时,取消本行注释。
rsDel.movenext
DeleteAFile(path)
end if
End Function
%>
<%
'DelteAFile(path)
Sub DeleteAFile(path)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile(path)
set fso=nothing
End Sub
%>正确的完整底码应该是这样的~贴出来以供大家参考! 展开
3个回答
展开全部
可使用FSO对象删除文件.
根据你图片的productid,获取该图片的路径,赋值给Path.
<%
DelteAFile(path)
Sub DeleteAFile(path)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile(path)
set fso=nothing
End Sub
%>
======================
呵呵,终于搞定,分数吖分数吖........
根据你图片的productid,获取该图片的路径,赋值给Path.
<%
DelteAFile(path)
Sub DeleteAFile(path)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile(path)
set fso=nothing
End Sub
%>
======================
呵呵,终于搞定,分数吖分数吖........
展开全部
想删除图片,必须有记录图片的位置信息,如过没有,是不能顺利删除的!
如果有路径,就用FSO直接删除就可以了,删除数据库记录没有什么。
如果有路径,就用FSO直接删除就可以了,删除数据库记录没有什么。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
可使用FSO对象删除文件.
根据你图片的productid,获取该图片的路径,赋值给Path.
<%
DelteAFile(path)
Sub
DeleteAFile(path)
Dim
fso
Set
fso
=
CreateObject("Scripting.FileSystemObject")
fso.DeleteFile(path)
set
fso=nothing
End
Sub
%>
======================
呵呵,终于搞定,分数吖分数吖........
根据你图片的productid,获取该图片的路径,赋值给Path.
<%
DelteAFile(path)
Sub
DeleteAFile(path)
Dim
fso
Set
fso
=
CreateObject("Scripting.FileSystemObject")
fso.DeleteFile(path)
set
fso=nothing
End
Sub
%>
======================
呵呵,终于搞定,分数吖分数吖........
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询