festusmule
asked on
Parameterized update or refresh statement/ Data provider or other service returned an E_Fail status
Hi...
I am trying to make a vbs script run to input NT Event Log info into an Access database...thats all!
the code for the script is directly from MS script center and is pasted below.
The problem is that when the script is run, it fails on line 22 with one of two errors depending on which machine/environment it is executed in.
1. Data provider or other service returned an E_Fail status
2. Conversion error occured while building parameterized update or refresh statement
In both cases I am running w2k server sp 4 all patches latest MDAC 2.7 refresh etc etc...My Access mdb has all the required fields, and DSN I think is correct. I have tried using both drivers that are available in the ODBC control panel. This does not seem to have any effect.
Any input is appreciated.
Set objConn = CreateObject("ADODB.Connec tion")
Set objRS = CreateObject("ADODB.Record set")
objConn.Open "DSN=EventLogs;"
objRS.CursorLocation = 3
objRS.Open "SELECT * FROM EventTable" , objConn, 3, 3
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper sonate}!\\ " & strComputer & "\root\cimv2")
Set colRetrievedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent")
For Each objEvent in colRetrievedEvents
objRS.AddNew
objRS("Category") = objEvent.Category
objRS("ComputerName") = objEvent.ComputerName
objRS("EventCode") = objEvent.EventCode
objRS("Message") = objEvent.Message
objRS("RecordNumber") = objEvent.RecordNumber
objRS("SourceName") = objEvent.SourceName
objRS("TimeWritten") = objEvent.TimeWritten
objRS("Type") = objEvent.Type
objRS("User") = objEvent.User
objRS.Update
Next
objRS.Close
objConn.Close
Any help would be very much appreciated.
OH I almost forgot to mention, that data from the event logs IS BEING populated into the database....but these errors occur none the less...
I am trying to make a vbs script run to input NT Event Log info into an Access database...thats all!
the code for the script is directly from MS script center and is pasted below.
The problem is that when the script is run, it fails on line 22 with one of two errors depending on which machine/environment it is executed in.
1. Data provider or other service returned an E_Fail status
2. Conversion error occured while building parameterized update or refresh statement
In both cases I am running w2k server sp 4 all patches latest MDAC 2.7 refresh etc etc...My Access mdb has all the required fields, and DSN I think is correct. I have tried using both drivers that are available in the ODBC control panel. This does not seem to have any effect.
Any input is appreciated.
Set objConn = CreateObject("ADODB.Connec
Set objRS = CreateObject("ADODB.Record
objConn.Open "DSN=EventLogs;"
objRS.CursorLocation = 3
objRS.Open "SELECT * FROM EventTable" , objConn, 3, 3
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper
Set colRetrievedEvents = objWMIService.ExecQuery _
("Select * from Win32_NTLogEvent")
For Each objEvent in colRetrievedEvents
objRS.AddNew
objRS("Category") = objEvent.Category
objRS("ComputerName") = objEvent.ComputerName
objRS("EventCode") = objEvent.EventCode
objRS("Message") = objEvent.Message
objRS("RecordNumber") = objEvent.RecordNumber
objRS("SourceName") = objEvent.SourceName
objRS("TimeWritten") = objEvent.TimeWritten
objRS("Type") = objEvent.Type
objRS("User") = objEvent.User
objRS.Update
Next
objRS.Close
objConn.Close
Any help would be very much appreciated.
OH I almost forgot to mention, that data from the event logs IS BEING populated into the database....but these errors occur none the less...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Alan