Link to home
Start Free TrialLog in
Avatar of festusmule
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.Connection")
Set objRS = CreateObject("ADODB.Recordset")
objConn.Open "DSN=EventLogs;"
objRS.CursorLocation = 3
objRS.Open "SELECT * FROM EventTable" , objConn, 3, 3
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & 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...
ASKER CERTIFIED SOLUTION
Avatar of Alan Warren
Alan Warren
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also check your dsn, connection might be forward only or readonly (FireHose)

Alan