我正在尝试在C#应用程序中实现MS LogParser。这可以在logQuery.ExecuteBatch()方法中编译精细但无法解释的崩溃。 try / catch块没有捕获它,除非我特别错误的szQuery,这表明一切正常,我只是没有得到任何输出。
有关它可能崩溃的原因或我可能会发现某些记录的任何想法吗?
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 { }; } }
}
答案 0 :(得分:1)
使用Execute而不是ExecuteBatch:
MSUtil.ILogRecordset RecordSet = logQuery.Execute(query, oInputFormat)
如果要在示例代码中导出为CSV,则需要通过添加INTO output_file_name并运行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";