getValue Method

Returns the value of the field at the specified position in the record.


Script Syntax

value = objRecord.getValue( index );
value = objRecord.getValue( fieldName );

Parameters

index
An integer containing the 0-based index of the 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.
fieldName
A string containing the name of the field in the query output records.

Return Value

The value of the specified field.
The value is returned as a VARIANT (i.e. a scripting variable) whose type depends on the data type of the field. The following table shows the VARIANT type returned and the corresponding scripting types for each of the Log Parser data types:
Field Type VARIANT Type JScript Type VBScript Type
INTEGER VT_I4 number Long
REAL VT_R8 number Double
STRING VT_BSTR string String
TIMESTAMP VT_DATE date (VB date) Date
NULL VT_NULL null object Null

Remarks


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.getValue("TimeGenerated") );
		WScript.Echo( "SourceName   : " + oRecord.getValue(1) ); 
		WScript.Echo( "EventID	: " + oRecord.getValue(2) ); 
		if( !oRecord.isNull(3) )
		{
			WScript.Echo( "Message	: " + oRecord.getValue(3) ); 
	}
		else
		{
			WScript.Echo( "Message	: <null>" ); 
	}

		// 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.getValue("TimeGenerated")
		WScript.Echo "SourceName   : " & oRecord.getValue(1)
		WScript.Echo "EventID	: " & oRecord.getValue(2)
		If oRecord.isNull(3) = False Then 
			WScript.Echo "Message	: " & oRecord.getValue(3)
		Else
			WScript.Echo "Message	: <null>"
		End If

		' 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.