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)文章
垃圾引用防治補(bǔ)丁以及發(fā)送引用修正補(bǔ)丁的自動(dòng)安裝程序
垃圾引用防治補(bǔ)丁以及發(fā)送引用修正補(bǔ)丁的自動(dòng)安裝程序...2007-02-02
ASP + Serv-u 實(shí)現(xiàn)FTP的代碼
ASP + Serv-u 實(shí)現(xiàn)FTP的代碼...2006-10-10
asp中將相對(duì)路徑轉(zhuǎn)換為絕對(duì)路徑的函數(shù)代碼
一個(gè)將絕對(duì)路徑轉(zhuǎn)換為相對(duì)路徑的asp函數(shù),需要的朋友可以收藏下。2011-05-05
asp CutStrX字符串截取函數(shù)(過濾全部HTML標(biāo)記)
asp CutStrX字符串截取函數(shù)(過濾全部HTML標(biāo)記),比較不錯(cuò),需要的朋友可以參考下。2011-07-07
asp刪除mssql數(shù)據(jù)庫(kù)中沒有記錄的圖片代碼
asp刪除沒有記錄的圖片需要文件夾(存放圖片的文件夾)中的每個(gè)圖片和數(shù)據(jù)庫(kù)中的所有記錄進(jìn)行比較2009-08-08
asp中格式化HTML函數(shù)代碼 SDCMS加強(qiáng)版
主要用來去除html中的script,iframe等html標(biāo)記,需要的朋友可以參考下。2011-01-01
ASP下通過Adodb.Stream實(shí)現(xiàn)多線程下載大文件
這篇文章主要介紹了ASP下通過Adodb.Stream實(shí)現(xiàn)多線程下載大文件,需要的朋友可以參考下2020-08-08

