getColumnType Method

Log Parser

getColumnType Method

Returns the type of a field in the query output records.

Script Syntax

value = objRecordSet.getColumnType( 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

An integer value containing the type of the output record field at the specified position.
This value is one of the constants returned by the INTEGER_TYPE, REAL_TYPE, STRING_TYPE, TIMESTAMP_TYPE, and NULL_TYPE properties.


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 Object
Log Parser COM API Overview
C# Example


© 2004 Microsoft Corporation. All rights reserved.