toNativeString Method

Log Parser

toNativeString Method

Returns a field or the whole output record as a string value.

Script Syntax

value = objRecord.toNativeString( index );
value = objRecord.toNativeString( separator );


Parameters

index
An integer containing the 0-based index of a field in the query output records. The index must be less than the number of fields returned by the getColumnCount method of the LogRecordSet object.
separator
A string containing the separator to be used between the fields of the record.


Return Value

If a field index is used as argument, the method returns the specified field formatted to a string according to the input format string representation of the data type. For example, if the input format used parses timestamps formatted as 'yyyy-MM-dd hh:mm:ss', then the method formats TIMESTAMP values using the same format.
If a string separator is used as argument, the method returns the concatenation of all the record fields formatted to a string, separated by the specified separator.


Examples

JScript example:

var oLogQuery = new ActiveXObject("MSUtil.LogQuery");

// Create query text
var strQuery = "SELECT TimeGenerated, SourceName, EventID, Message FROM System";

// Execute query and receive a LogRecordSet
var oRecordSet = oLogQuery.Execute( strQuery );

// Visit all records
while( !oRecordSet.atEnd() )
{
        // Get a record
        var oRecord = oRecordSet.getRecord();

        // Display record information
        WScript.Echo( "TimeGenerated: " + oRecord.toNativeString(0) );
        WScript.Echo( "Whole Record:  " + oRecord.toNativeString(", ") ); 

        // Advance LogRecordSet to next record
        oRecordSet.moveNext();
}

// Close LogRecordSet
oRecordSet.close();

VBScript example:

Dim oLogQuery
Dim oRecordSet
Dim strQuery
Dim f
Dim val

Set oLogQuery = CreateObject("MSUtil.LogQuery")

' Create query text
strQuery = "SELECT TimeGenerated, SourceName, EventID, Message FROM System"

' Execute query and receive a LogRecordSet
Set oRecordSet = oLogQuery.Execute( strQuery )

' Visit all records
DO WHILE NOT oRecordSet.atEnd

	' Get a record
	Set oRecord = oRecordSet.getRecord

        ' Display record information
        WScript.Echo "TimeGenerated: " & oRecord.toNativeString(0)
        WScript.Echo "Whole Record:  " & oRecord.toNativeString(", ")

	' Advance LogRecordSet to next record
	oRecordSet.moveNext

LOOP

' Close RecordSet
oRecordSet.close


See also:

LogRecord Object
Log Parser COM API Overview
C# Example


© 2004 Microsoft Corporation. All rights reserved.