churchlandsshs
asked on
VBScript write to ODBC database on remote machine
Using VBScript I need to write data to an Access database on a remote machine.
At the moment, I have the script below, which works perfectly, but requires me to manually set up the ODBC first.
What is the best way to automate being able to write to the remote database?
500 points, because it is fairly urgent.
At the moment, I have the script below, which works perfectly, but requires me to manually set up the ODBC first.
What is the best way to automate being able to write to the remote database?
500 points, because it is fairly urgent.
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DSN=Test;"
objRecordset.CursorLocation = adUseClient
strIPaddr = "10.0.0.1"
strComputerName = "test"
strSerialNumber = "90556"
strLocation = "administration"
strYear = "2009"
strInformation = "This is a test to see if the script works"
objRecordset.Open "SELECT * FROM Computers" , objConnection, adOpenStatic, adLockOptimistic
objRecordset.AddNew
objRecordset("ComputerName") = strComputerName
objRecordset("YearAcquired") = strYear
objRecordset("Location") = strLocation
objRecordset("Information") = strInformation
objRecordset("SerialNumber") = strSerialNumber
objRecordset.Update
objRecordset.Close
objConnection.Close
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Used my script, but changed the objConnection.Open command to:
objConnection.Open "Provider=Microsoft.Jet.OL EDB.4.0;Da ta Source=\\server\share\fold er\databas e.mdb"
objConnection.Open "Provider=Microsoft.Jet.OL
The best way I can think to do it is export the HKEY_LOCAL_MACHINE\SOFTWAR
Then save it on the network as MyAcc.REG
Then in your script have a command
--------------------------
REGEDIT -S \\MyServer\MyShare\MyAcc.R
--------------------------
to load it on a machine.
Open in new window