Reading Trace file using VB Script

  • Hi all,

     

    Is there anyway to read the trace file using vb script ?

    can anybody help me to do this ?


    subban

  • Here is an example script that may do what you need.  It uses an adodb connection and resultset object, and the sql function fn_trace_gettable.

    Dim adoConn

    Set adoConn = CreateObject("ADODB.Connection")

    Dim adoRs

    Set adoRs = CreateObject("ADODB.Recordset")

    sConn = "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=Master;Trusted_Connection=yes;"

    adoConn.ConnectionString = sConn

    adoConn.Open

    Set adoRs = adoConn.Execute("SELECT * FROM ::fn_trace_gettable('C:\temp\trace1.trc', default)")

    While not adoRs.Eof

     wscript.echo "" & adors("loginname")

     adoRs.Movenext

    Wend

    adoRs.Close

    adoConn.Close

    Hope this helps.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply