วันพุธที่ 22 มิถุนายน พ.ศ. 2554

VBA-Ms Access Create_Batfile


Function Create_Batfile()
Set fs = CreateObject("Scripting.FileSystemObject")
'Set a = fs.CreateTextFile("C:\Zr506\update.sql", True)
'a.writeline ("UPDATE  configuration SET last_date ='" & EngDate(Last_Date) & "';")
'a.Close
txtServer = "localhost"

Set a2 = fs.CreateTextFile("C:\Zr506\update.bat", True)
Set rsz = CurrentDb.OpenRecordset("SELECT * FROM disease ")
Do While Not rsz.EOF
codedz = rsz.Fields("codedz")
    a2.writeline ("" & Postgres_Path & "psql -d " & Postgres_DB & " -f C:\Zr506\sick_r506_" & codedz & ".sql  -U postgres  -h  " & txtServer & "")
    a2.writeline ("" & Postgres_Path & "psql -d " & Postgres_DB & " -f C:\Zr506\death_r506_" & codedz & ".sql  -U postgres  -h  " & txtServer & "")
   
rsz.MoveNext
Loop


a2.writeline ("" & Postgres_Path & "psql -d " & Postgres_DB & " -f C:\Zr506\update.sql -U postgres  -h  " & txtServer & "")
a2.Close
stAppName = "C:\Zr506\update.bat"  '¤Ø³µéͧà»ÅÕè¹ Drive áÅÐ Path ¤ÃѺ
Call Shell(stAppName, 3)
End Function

ไม่มีความคิดเห็น:

แสดงความคิดเห็น