0
votes

I'm trying to implement MS LogParser in a C# application. This compiles fine but inexplicably crashes on the logQuery.ExecuteBatch() method. The try/catch block doesn't catch it unless I specifically malform the szQuery, which suggests that everything is working as it should, I'm just not getting any output.

Any thoughts on why it might be crashing or where I might find some logging?


using System; using System.Collections.Generic; using System.Linq; using System.Text; using FolderLoggingLib; using MSUtil;

namespace ConsoleApplication20 { class Program { static void Main(string[] args) { //refLog = new BinaryInputFormat(); LogQueryClass logQuery = new LogQueryClass(); ICOMCSVOutputContext output = new COMCSVOutputContextClass(); ILogParserInputContext parse = new BinaryInputFormat();

string szFileName = @"E:\Programming\FolderLogging\2012-05-13.fbl"; string szQuery = "SELECT Folder, User, Record, DB, TO_LOCALTIME(Timestamp) AS DateTime, Operation, Checked FROM " + szFileName + " ORDER BY DateTime DESC"; try { logQuery.ExecuteBatch(szQuery, parse, output); } catch { }; } }

}

1
try catch(Exception ex) to see what exception you get and post the details.Peter Ritchie
Tried - it never reaches the catch block, the program just dies on the logQuery.ExecuteBatch() method.David M

1 Answers

1
votes

Use Execute instead of ExecuteBatch:

MSUtil.ILogRecordset RecordSet = logQuery.Execute(query, oInputFormat)

If you want to export to CSV in your sample code you need to change the query by adding INTO output_file_name and run ExecuteBatch:

string szQuery = "SELECT Folder, User, Record, DB, TO_LOCALTIME(Timestamp) AS DateTime, Operation,  Checked **INTO c:\out\out.csv** FROM " + szFileName + " ORDER BY DateTime DESC";