getColumnName Method
Returns the name of a field in the query output records.
Script Syntax
value = objRecordSet.getColumnName( index );
Parameters
- index
- 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.
Return Value
A string value containing the name of the output record field at the specified position.
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