« Previous Next »

Thread: Querying logs having single quotes in field data.

Last post 10-29-2009 2:55 AM by rhitam_sanyal. 1 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (2 items)

Sort Posts:

  • 10-29-2009, 2:27 AM

    Querying logs having single quotes in field data.

    Hi all I am trying to use the logparser vis COM using c# code . I am usign a function pareLog which returns a dataset after querying the TSV file . Lets say I have a data which looks like this : Field1 Field2 Data1 Da'ta2nsomemore Notice the single quote in the data under field2.Now my query looks something like this : string strSQL = "select * from 'C:\20091014_ErrorLogs.log' where Field2 like '%Da'ta'"; Dataset DS = parselog(strsql); the parselog function i am using from the following link : http://www.leastprivilege.com/UsingLogParserFromC.aspx obviously the above query is throwing an exception since anything after the second single quote in the where condition is taken as a part of the query. So how to tackle this problem ? Any help greatly appreciated.
  • 10-29-2009, 2:55 AM In reply to

    Re: Querying logs having single quotes in field data.

    Never mind : string strSQL = "select * from 'C:\20091014_ErrorLogs.log' where Field2 like '%Da\'ta'" Escape the single quote :)
Page 1 of 1 (2 items)
Microsoft Communities