データベースのテーブルの内容を書き換える前に、内容をファイルに保存したい場合のサンプルです。
'
' ログの書き出し
'
Function WF_SQL_LOG(AP_name,SQL)
Dim today,today_time,DIR,pcname
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set Fs = CreateObject("Scripting.FileSystemObject")
today = Right("00"+CStr(Year(Date)),2) + Right("00"+CStr(Month(Date)),2) + Right("00"+CStr(Day(Date)),2)
today_time = Right("00"+CStr(hour(Time)),2) + Right("00"+CStr(Minute(Time)),2) + Right("00"+CStr(Second(Time)),2)
DIR = Server.MapPath("/is/wf/log/" & AP_name & today & ".log")
pcname = Request.ServerVariables("REMOTE_HOST")
Set TLog = Fs.OpenTextFile(DIR, ForAppending, True)
RET = TLog.WriteLine(today_time & " : " & pcname & " - " & SQL)
TLog.Close
set TLog = Nothing
set FS = Nothing
End Function
'
'使い方
'SQL = "select * from wf02 where serial = '" & serial & "'"
'Set RS = Conn.Execute(SQL)
'WF_Back_Log "WF02",RS,"wf02"
'
Function WF_Back_Log(AP_Name,RS_Back,DB_name)
Dim wf_i,SQL
Do until RS_Back.EOF
SQL = "- repair " & DB_name & " - "
for wf_i=0 to RS_Back.fields.count - 1
SQL = SQL & RS_Back.fields(wf_i).name & ","
next
WF_SQL_LOG AP_Name,SQL
SQL = "- repair " & DB_name & " - "
for wf_i=0 to RS_Back.fields.count - 1
SQL = SQL & RS_Back(wf_i) & ","
next
WF_SQL_LOG AP_Name,SQL
RS_Back.MoveNext
Loop
end function

