Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

WMI Data Reader task gets error "Operation is not valid due to the current state of the object" for Event Log query with date filter

$
0
0

Ive got a WMI Data Reader task that is using a query like this, which is set in a script task.
"SELECT * FROM Win32_NtLogEvent WHERE Logfile='Application' AND Type='error' AND TimeGenerated > '3/10/2015'"

If I take off the TimeGenerated part, the DataReader task succeeds, but with it I get an error

"Operation is not valid due to the current state of the object"

Ive had issues with time formats before when dealing with WMI, is this a case where the time format comes into question?

I tried with UTC time format and still get the same error.  I really need to be able to filter based on date/time.  Since Im filling in a DataTable with the WMI results, I suppose I could filter the DT for the date...

The WQL statement Im using is being built like this (using UTC time)

Dts.Variables["User::wmi_query_string"].Value = "SELECT * FROM Win32_NtLogEvent WHERE Logfile='Application' AND Type='error' AND TimeGenerated > '" + DateTime.Now.AddDays(-1).ToUniversalTime() + "'";


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>