isNull Method

Returns a Boolean value indicating if an output record field is NULL.


Script Syntax

value = objRecord.isNull( index );
value = objRecord.isNull( 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

A Boolean value indicating if the specified output record field is NULL.

Examples

JScript example:

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

// Create query text
var strQuery = "SELECT TimeGenerated, SourceName, EventID, Message, Data 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>" ); 
	}

		if( !oRecord.isNull("Data") )
		{
			WScript.Echo( "Data		 : " + oRecord.getValue(4) ); 
	}
		else
		{
			WScript.Echo( "Data		 : <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, Data 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

		If oRecord.isNull("Data") = False Then 
			WScript.Echo "Data		 : " & oRecord.getValue(4)
		Else
			WScript.Echo "Data		 : <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.