asp刪除mssql數(shù)據(jù)庫(kù)中沒有記錄的圖片代碼
更新時(shí)間:2009年08月30日 20:54:28 作者:
asp刪除沒有記錄的圖片需要文件夾(存放圖片的文件夾)中的每個(gè)圖片和數(shù)據(jù)庫(kù)中的所有記錄進(jìn)行比較
采用雙重循環(huán)。把圖片進(jìn)行“.”分割后名字問前面部分,那其余數(shù)據(jù)庫(kù)中的 圖片路徑記錄進(jìn)行對(duì)比
采用vb的InStr函數(shù) 如果存在的話返回值>0,過可以得出結(jié)論
代碼如下deal.asp
<%@ language="vbscript"%>
<%response.Expires = 0%>
<!--#include file="conn.asp"-->
<%
Dim objFSO,objFolder,objFile,FF '聲明 objFSO 變量存放對(duì)象實(shí)例
FF = Server.MapPath("pro_s/")
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(ff) Then
Response.write "文件夾 "&ff&" 里所有的文件:<br>"
Set objFolder = objFSO.GetFolder(ff)
For Each objFile in objFolder.Files
%>
<%
filename=cstr(objFile.name)
myname=split(filename,".")
ffname=myname(0)
a=0
set sclass=conn.execute("select img from wksc_pro ")
do while not sclass.eof
result=Instr(sclass("img"),ffname)
a=a+result
if(a>0) then
exit do
end if
sclass.movenext
loop
if(a=0) then
response.Write ""&objFile&""
response.Write"<br>"
objFile.delete
end if
%>
<%
Next
Else
Response.Write "文件夾"&ff&"不存在,無法讀取相關(guān)信息!"
End If
Set objFolder = Nothing
Set objFSO = Nothing '釋放 FileSystemObject 對(duì)象實(shí)例內(nèi)存空間
%>
來自:http://blog.csdn.net/lingfeng179/archive/2009/08/19/4463679.aspx
采用vb的InStr函數(shù) 如果存在的話返回值>0,過可以得出結(jié)論
代碼如下deal.asp
復(fù)制代碼 代碼如下:
<%@ language="vbscript"%>
<%response.Expires = 0%>
<!--#include file="conn.asp"-->
<%
Dim objFSO,objFolder,objFile,FF '聲明 objFSO 變量存放對(duì)象實(shí)例
FF = Server.MapPath("pro_s/")
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(ff) Then
Response.write "文件夾 "&ff&" 里所有的文件:<br>"
Set objFolder = objFSO.GetFolder(ff)
For Each objFile in objFolder.Files
%>
<%
filename=cstr(objFile.name)
myname=split(filename,".")
ffname=myname(0)
a=0
set sclass=conn.execute("select img from wksc_pro ")
do while not sclass.eof
result=Instr(sclass("img"),ffname)
a=a+result
if(a>0) then
exit do
end if
sclass.movenext
loop
if(a=0) then
response.Write ""&objFile&""
response.Write"<br>"
objFile.delete
end if
%>
<%
Next
Else
Response.Write "文件夾"&ff&"不存在,無法讀取相關(guān)信息!"
End If
Set objFolder = Nothing
Set objFSO = Nothing '釋放 FileSystemObject 對(duì)象實(shí)例內(nèi)存空間
%>
來自:http://blog.csdn.net/lingfeng179/archive/2009/08/19/4463679.aspx
您可能感興趣的文章:
- Windows 2003 IIS 6.0 搭建可建虛擬機(jī)的asp+.net+php+jsp+mysql+mssql
- ASP控制每頁打印行數(shù)
- asp循環(huán)行數(shù)輸出函數(shù)
- asp php 清空access mysql mssql數(shù)據(jù)庫(kù)的代碼
- ASP+MSSQL2000 數(shù)據(jù)庫(kù)被批量注入后的解決方法
- asp連接mssql2005的代碼
- asp實(shí)現(xiàn)的查詢某關(guān)鍵詞在MSSQL數(shù)據(jù)庫(kù)位置的代碼
- asp實(shí)現(xiàn)獲取MSSQL數(shù)據(jù)庫(kù)表指定條件行數(shù)的函數(shù)
相關(guān)文章
asp中回車換行符CHR(10)表示換行,CHR(13)表示回車,CHR(32)表示空格
這篇文章主要介紹了asp中回車換行符CHR(10)表示換行,CHR(13)表示回車,CHR(32)表示空格,需要的朋友可以參考下2006-08-08用asp實(shí)現(xiàn)的截取指定格式字符串的代碼
用asp實(shí)現(xiàn)的截取指定格式字符串的代碼...2007-11-11ASP計(jì)算str2在str1中出現(xiàn)的次數(shù)
可以方便計(jì)算一個(gè)字符串在另一個(gè)字符串出現(xiàn)的次數(shù)2008-05-05使用FSO把文本信息導(dǎo)入數(shù)據(jù)庫(kù)
使用FSO把文本信息導(dǎo)入數(shù)據(jù)庫(kù)...2006-08-08