Hi all, I am working on small project using C# (2005) to use LogParser to query a particular server to grab it's log and transfer the log to SQL2005.
I am able to do so if I access the LogParser through IE (through interface like letting the user select the server, date/time to parse etc). But when I transfer the entire script into Windows Service, I cannot get anything at all.
Below is part of the codes that I have. For the Windows Service part, if I were to comment off the line LogRecordSet oRecordSet = oLogQuery.Execute( query, oEVTInputFormat ); it works (as in if I were to .write the query string out, I am able to) but when I put that line in, nothing happens although the service is started. Hope some experts here can help me! Thanks in advance!
LogQuery oLogQuery = new LogQuery();
EventLogInputFormat oEVTInputFormat = new EventLogInputFormat();
oEVTInputFormat.direction = "BW";
string query = @"SELECT * FROM ";
if ( _ip != null )
{
if ( _ip != "local" )
{
query = query + "\\\\" + _ip + "\\SYSTEM";
}
}
query = query + " WHERE (1 = 1)";
if ( _lastmessageon != null )
{
query = query + " AND (TO_DATE(TimeGenerated) > TO_DATE(TIMESTAMP( '" + Common.MyFunctions.FormatDateTime( _lastmessageon, "yyyy-MM-dd hh:mm:ss" ) + "', 'yyyy-MM-dd hh:mm:ss')))";
}
LogRecordSet oRecordSet = oLogQuery.Execute( query, oEVTInputFormat );
.... (codes to insert into SQL2005)
oRecordSet.close();