0

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 { }; } }

}

2
  • 1
    try catch(Exception ex) to see what exception you get and post the details. Commented May 14, 2012 at 17:12
  • Tried - it never reaches the catch block, the program just dies on the logQuery.ExecuteBatch() method. Commented May 14, 2012 at 17:13

1 Answer 1

1

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";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.