动网风格分析助手

一、rstotxt.asp:

<%
Dim objConn,objRs,objFSO,objTS
Dim i
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRs = Server.CreateObject("ADODB.RecordSet")
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
objConn.connectionstring = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & Server.MapPath("Dvbbs7.mdb")
objConn.open
objRs.open "select * from Dv_Style where id=1",objConn,1,3
If not objRs.eof Then
    For i = 0 to objRs.fields.count-1
        'If objRs(i).name="Main_Style" Then '导出指定字段
            Set objTS = objFSO.CreateTextFile(Server.MapPath(objRs(i).name & ".txt"))
            objTS.write objRs(i).value
            objTS.close
            Set objTS = nothing
        'End if
    Next
End if
Set objFSO = nothing
objRs.close
Set objRs =nothing
objConn.close
Set objConn = nothing
%>

以各字段名做文件名,并将其内容分别保存于txt文件中,当然,也可保存成htm文件。

二、rstofolder.asp:

<%
Dim objConn,objRs,objFSO,objTS
Dim i,j,strTemp,arrTemp
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRs = Server.CreateObject("ADODB.RecordSet")
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
objConn.connectionstring = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & Server.MapPath("Dvbbs7.mdb")
objConn.open
objRs.open "select * from Dv_Style where id=1",objConn,1,3
If not objRs.eof Then
    For i = 0 to objRs.fields.count-1
        'If objRs(i).name="page_index" Then '导出指定字段
            strTemp = Server.MapPath(".") & "\" & objRs(i).name
            objFSO.CreateFolder(strTemp)
            arrTemp = split(objRs(i).value,"|||")
            For j=LBound(arrTemp) to UBound(arrTemp)
                Set objTS = objFSO.CreateTextFile(strTemp & "\" & j & ".txt")
                objTS.write arrTemp(j)
                objTS.close
                Set objTS = nothing
            Next
        'End if
    Next
End if
Set objFSO = nothing
objRs.close
Set objRs =nothing
objConn.close
Set objConn = nothing
%>

以各字段名为文件夹名,并将字段内容以"|||"为分割点分别保存于txt文件中,也可保存为htm文件。

评论: 1 | 引用: 0 | 查看次数: 4123
发表评论
登录后再发表评论!