Forum Moderators: DixonJones
How in the world do you use it?
I want to do a simple query of the log file in VB.
Thanks
I will admit I had trouble spotting it at first so I browsed to the directory and selected the "LogParser.dll" (essentially force registration & select) - at which point the "MS Utility Type Library - Log Parser" entry was highlighted for me.
From here the object browser seems to suggest that MSUtil is the root object with the logical start point being the LogQueryClass with its Execute method.
Don't take this the wrong way but if you couldn't get this far I think interacting with an interface which includes minimal documentation isn't for you.
If you still want to try I recommend reading page 40 onwards of the manual that gets installed (LogParser.doc) as this relates to the interface, although as expected this describes it in a style suitable for C rather than VB.
- Tony
ILogRecordset Execute( BSTR szQuery [, InputSource] )This method executes the specified SQL-type query. If InputSource is not specified, the LogQuery object tries to determine what InputSource to use based on the FROM statement. The method returns a LogRecordset object.
So essentially as I thought earlier you want to use the MSUtil.LogQueryClass and give it your query plus an optional input source - in return it gives you an recordset containing the results. Which is nice.
(note that the inputsource appears to be one of the inputtype objects)
A combination of the object browser, reading the manual and trial+error should see you through...
- Tony
Private Sub Command1_Click()
Dim objParser As MSUtil.LogQueryClass
Set objParser = New MSUtil.LogQueryClass
Dim rs As MSUtil.ILogRecordset
Dim sql As String
sql = _
"SELECT " & _
"* " & _
"FROM C:\LogPArseTest\ex0302.log "
Set rs = objParser.Execute(sql)
Dim logrecord As MSUtil.ILogRecord
Do Until rs.atEnd
Set logrecord = rs.getRecord
Debug.Print logrecord.getValue(2)
rs.moveNext
Loop
End Sub