'----------------- '@author Duncan Rounding - Genesis Technical Ltd - www.genesistechnical.com '@date 2009/04/22 '@version 0.1 '@history '0.1 Initial 2009/04/22 '----------------- 'This script will allow entry of a SQL script and execute it on a selected Microsoft Access database. 'Use at your own risk '----------------- ON ERROR RESUME NEXT Set ObjFSO = CreateObject("UserAccounts.CommonDialog") ObjFSO.Filter = "Access Databases|*.mdb|All Files|*.*" ObjFSO.FilterIndex = 1 InitFSO = ObjFSO.ShowOpen If InitFSO = False Then Wscript.Echo "You didn't select a file!" Wscript.Quit End If mydb = ObjFSO.FileName sData = InputBox("Copy the SQL query you want to execute into the input box") strAutoset = MsgBox("This will update the selected database with the SQL query." & vbcrlf & vbcrlf & "BACKUP THE YOUR DATABASE BEFORE CONTINUING" & vbcrlf & vbcrlf &"Select 'Yes' to go ahead and update the database - wait for the update to finish." & vbcrlf & "Select 'No' to cancel." ,4) If (strAutoset = vbYes) then Set OBJdbConnection = CreateObject("ADODB.Connection") OBJdbConnection.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & mydb SQLQuery = sData Set Result = OBJdbConnection.Execute(SQLQuery) OBJdbConnection.Close msgbox("Completed - Database updated") Else msgbox("Aborted - Database not updated") End If