ป่าวครับเป็นไฟล์ script ครับ
'Open text file
Dim DemoTran,MyLogFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim MyDate
MyDate = DatePart("yyyy",Date) _
& Right("0" & DatePart("m",Date), 2) _
& Right("0" & DatePart("d",Date), 2)
Dim MyTime
MyTime = Time
'Check file on location
If objFSO.FileExists("C:\Users\Tarhunter\Documents\VBScript\Create Text File\test.csv") Then
Set objTextFile = objFSO.OpenTextFile("test.csv", 1)
Set DemoTran = objFSO.CreateTextFile("C:\Users\Tarhunter\Documents\VBScript\Create Text File\File Tran\"&"TestInsert"&MyDate& ".txt")
'Import database to SQL server
Dim count_row
count_row = 0
do while not (objTextFile.AtEndOfStream)
' objFSO.MoveFile "C:\Users\Tarhunter\Documents\VBScript\Create Text File\test.csv", "C:\Users\Tarhunter\Documents\VBScript\Create Text File\Backup\"
objFSO.CopyFile "C:\Users\Tarhunter\Documents\VBScript\Create Text File\test.csv", "C:\Users\Tarhunter\Documents\VBScript\Create Text File\Backup\"
objFSO.DeleteFile "C:\Users\Tarhunter\Documents\VBScript\Create Text File\test.csv"
Set MyLogFile = objFSO.CreateTextFile("C:\Users\Tarhunter\Documents\VBScript\Create Text File\File Log\"&MyDate& ".txt")
MyLogFile.WriteLine("Date : "& MyDate)
MyLogFile.WriteLine("Time : "&MyTime)
Dim MyProcess
Dim TypeProcess
TypeProcess = "Backup Data"
MyLogFile.WriteLine("Process : "&TypeProcess)
Dim StatusProcess
MyLogFile.WriteLine("Data in process : "&count&" "&"row")
StatusProcess = "Complete"
MyLogFile.WriteLine("Status : "&StatusProcess)
MyLogFile.WriteLine("......................................................................................................................")
MyLogFile.Close
Else
Set MyLogFile = objFSO.CreateTextFile("C:\Users\Tarhunter\Documents\VBScript\Create Text File\File Log\"&MyDate& ".txt")
MyLogFile.WriteLine("Date : "& MyDate)
MyLogFile.WriteLine("Time : "&MyTime)
MyLogFile.WriteLine("Process : Backup Data.")
MyLogFile.WriteLine("Status : File Not Found.!")
MyLogFile.WriteLine("......................................................................................................................")
MsgBox("File Not Found.!")
MyLogFile.Close
End If