Ordinal Property

DataColumn.Ordinal Property

Gets the position of the column in the DataColumnCollection collection.

[Visual Basic]
Public ReadOnly Property Ordinal As Integer
[C#]
public int Ordinal {get;}
[C++]
public: __property int get_Ordinal();
[JScript]
public function get Ordinal() : int;

Property Value

The position of the column. Gets -1 if the column is not a member of a collection.

Example

[Visual Basic, C#, C++] The following example returns the column name, ordinal, and data type of a column.

[Visual Basic] 
Private Sub PrintColumnDetails(ByVal myColumn As DataColumn)
    ' Print the Ordinal, ColumnName, and DataType of the column.
    Console.WriteLine(myColumn.Ordinal)
    Console.WriteLine(myColumn.ColumnName)
    Console.WriteLine(myColumn.DataType)
 End Sub

[C#] 
private void PrintColumnDetails(DataColumn myColumn){
    // Print the Ordinal, ColumnName, and DataType of the column.
    Console.WriteLine(myColumn.Ordinal);
    Console.WriteLine(myColumn.ColumnName);
    Console.WriteLine(myColumn.DataType);
 }

[C++] 
private:
void PrintColumnDetails(DataColumn* myColumn){
    // Print the Ordinal, ColumnName, and DataType of the column.
    Console::WriteLine(myColumn->Ordinal);
    Console::WriteLine(myColumn->ColumnName);
    Console::WriteLine(myColumn->DataType);
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

DataColumn Class | DataColumn Members | System.Data Namespace

Show:
© 2016 Microsoft