NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

ColumnsCollection.IndexOf

Returns the index of a column specified by name.

[Visual Basic]
Public Function IndexOf( _
   ByVal columnName As String _
) As Integer
[C#]
public int IndexOf(
   string columnName
);
[C++]
public: int IndexOf(
   String* columnName
);
[JScript]
public function IndexOf(
   columnName : String
) : int;

Parameters

columnName
The name of the column to return.

Return Value

The index of the column specified by columnName; otherwise,-1 if the column cannot be found.

Remarks

The IndexOf method is not case-sensitive.

Example [Visual Basic]

The following example uses the Contains method to determine if a specified column exists in a columns collection. If so, the IndexOf method returns the index of the column.

[Visual Basic]

Dim iCol As Integer
Dim cols As ColumnsCollection
' Get the ColumnsCollection from a DataTable in a DataSet.
cols = DataSet1.Tables("Orders").Columns

If cols.Contains("id") Then
     iCol = cols.IndexOf("id")
     Console.WriteLine(iCol, cols(iCol).DataType.ToString)
End If

See Also

ColumnsCollection Class | ColumnsCollection Members | System.Data Namespace