getColumnCount Method
Returns the number of fields in the query output records.
Script Syntax
value = objRecordSet.getColumnCount();
Return Value
An integer value containing the number of fields in the query output records.
Examples
JScript example:
var oLogQuery = new ActiveXObject("MSUtil.LogQuery"); // Create query text var strQuery = "SELECT * FROM System"; // Execute query and receive a LogRecordSet var oRecordSet = oLogQuery.Execute( strQuery ); // Display field names and types for( var f=0; f<oRecordSet.getColumnCount(); f++ ) { // Field Name WScript.Echo( "Field Name: " + oRecordSet.getColumnName(f) ); // Field type switch( oRecordSet.getColumnType(f) ) { case oRecordSet.INTEGER_TYPE: { WScript.Echo( "Field Type: INTEGER"); break; } case oRecordSet.REAL_TYPE: { WScript.Echo( "Field Type: REAL"); break; } case oRecordSet.STRING_TYPE: { WScript.Echo( "Field Type: STRING"); break; } case oRecordSet.TIMESTAMP_TYPE: { WScript.Echo( "Field Type: TIMESTAMP"); break; } case oRecordSet.NULL_TYPE: { WScript.Echo( "Field Type: NULL"); break; } } } // Close LogRecordSet oRecordSet.close();VBScript example:
Dim oLogQuery Dim oRecordSet Dim f Set oLogQuery = CreateObject("MSUtil.LogQuery") ' Create query text strQuery = "SELECT * FROM System" ' Execute query and receive a LogRecordSet Set oRecordSet = oLogQuery.Execute ( strQuery ) ' Display field names and types For f = 0 To oRecordSet.getColumnCount()-1 ' Field Name WScript.Echo "Field Name: " & oRecordSet.getColumnName(f) ' Field type Select Case oRecordSet.getColumnType(f) Case oRecordSet.INTEGER_TYPE WScript.Echo "Field Type: INTEGER" Case oRecordSet.REAL_TYPE WScript.Echo "Field Type: REAL" Case oRecordSet.STRING_TYPE WScript.Echo "Field Type: STRING" Case oRecordSet.TIMESTAMP_TYPE WScript.Echo "Field Type: TIMESTAMP" Case oRecordSet.NULL_TYPE WScript.Echo "Field Type: NULL" End Select Next ' Close LogRecordSet oRecordSet.close()
See also:
LogRecordSet ObjectLog Parser COM API Overview
C# Example