日期:2014-05-17  浏览次数:20812 次

删除数据库记录时同时删除图片?
删除数据库记录时同时删除图片?

------解决方案--------------------
set rsdan=server.createobject( "adodb.recordset ")
sql= "select * from BM_yuangong where Person_id in ( "&Person_id& ") "

set rsdan=rs(sql,conn)
'if not rsdan.eof then
while not rsdan.eof
if rsdan( "Person_zhaopian ") <> " " then
set fso=CreateObject( "Scripting.FileSystemObject ")
fso.deletefile(Server.Mappath(rsdan( "Person_zhaopian ")))
end if
rsdan.movenext
wend
'end if
'rscyc.delete
set rscyc=server.createobject( "adodb.recordset ")
sql= "delete from BM_yuangong where Person_id in ( "&Person_id& ") "
set rscyc=rs(sql,conn)
------解决方案--------------------
sql = "Select * From [t_product] where id= "&request( "tid ")& " "
set rs=Server.CreateObject( "adodb.recordset ")
rs.open sql,conn,1,1
Picture=rs( "picture ")
rs.close
set rs=Nothing
If Picture <> " " then
paths= "../UpPic/ " '图片目录
paths=paths+Picture
dim fso
set fso = createobject( "scripting.filesystemobject ")
fso.deletefile(server.mappath( " " & paths))
set fso = nothing
End If
conn.execute( "delete * from [t_product] where id= "&tid)