asp网页中文件删除问题(删除数据库中的记录和服务器目录下的文件)
adminupload.asp页面中的删除部分源码:(connUpload是一个记录集,记录集中包含U_id,U_filename,U_text等字段,其中U_filename存贮相对路径)
<a href="adminupdel.asp?U_id=<%=(connUpload.Fields.Item("U_id").Value)%>">删除</a>
adminupdel.asp页面的源代码:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/connTeainf.asp" -->
<%
if(request("U_id") <> "") then Command1__del_id = request("U_id")
%>
<%
set Command1 = Server.CreateObject("ADODB.Command")
strq1 = "select U_filename From uploadData where U_id =" + Replace(Command1__del_id, "'", "''") + " "
if strq1<>"" then
Dim fso
Set fso=Server.CreateObject("Scripting.FileSystemObject")
Dim filepath
filepath=server.mappath(strq1)
'删除文件---如果存在,则将其删除
IF fso.FileExists(filepath)=True Then
fso.DeleteFile filepath
End If
end if
Command1.ActiveConnection = MM_connTeainf_STRING
Command1.CommandText = "DELETE FROM uploadData WHERE U_id=" + Replace(Command1__del_id, "'", "''") + " "
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()
%>
<% Response.Redirect("adminupload.asp") %>
我执行以后怎么都删除不了目录下的文件啊。
请大家帮忙啊!