Skip to content

How to use inline Visual Basic .Net code?

Write the code between <% and %> marks, it will be executed and the result string will be replaced in the query. We believe this feature will be very useful for the users of Log Parser Lizard. For instance, before parsing logs you can move-copy-rename files, download from FTP, shutdown IIS, etc. You can also use .Net data types like DateTime for arithmetic operations and/or System.Envirenment settings in query parameters. This is a sample query with inline VB.Net code:

<%
'Do something here, for instance System.IO.File.Copy("c:\DailyLogs\*.log", "c:\AllLogs")
Return ""
%>

SELECT TOP 100 * FROM <1>
WHERE date >= '<% RETURN DateTime.Today.AddDays(-7).ToString("yyyy-MM-dd")%>' -- last week


The resulting query from this sample would be:

SELEC TOP 100 * FROM <1> WHERE date >= '2011-10-01' -- last week

This query will prompt for input of EventID:

select top 100 * from Application where EventID=<% return Microsoft.VisualBasic.Interaction.InputBox("Please enter Event ID","Event ID","1053") %>

Feedback and Knowledge Base