Share via


SqlCeDataReader.GetOrdinal Method

Gets the column ordinal, given the name of the column.

Namespace: System.Data.SqlServerCe
Assembly: System.Data.SqlServerCe (in system.data.sqlserverce.dll)

Syntax

'Declaration
Public Overrides Function GetOrdinal ( _
    name As String _
) As Integer
public override int GetOrdinal (
    string name
)
public:
virtual int GetOrdinal (
    String^ name
) override
public int GetOrdinal (
    String name
)
public override function GetOrdinal (
    name : String
) : int

Parameters

  • name
    The name of the column.

Return Value

The zero-based column ordinal.

Exceptions

Exception type Condition
IndexOutOfRangeException

The name specified is not a valid column name.

InvalidOperationException

The operation is not valid. The SqlCeDataReader may be positioned after the last row in the result set.

Remarks

GetOrdinal performs a case-sensitive lookup first. If it fails, a second case-insensitive search is made.

Because ordinal-based lookups are more efficient than named lookups, it is inefficient to call GetOrdinal within a loop. Save time by calling GetOrdinal once and assigning the results to an integer variable for use within the loop.

Thread Safety

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Windows Vista, Windows Mobile 5.0, Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Mobile 2003 for Pocket PC, Windows CE 5.0
Version Information
.NET Framework and NET Compact Framework
Supported in 3.5
.NET Framework
Supported in 3.0
.NET Compact Framework and .Net Framework
Supported in 2.0

See Also

Reference

SqlCeDataReader Class
SqlCeDataReader Members
System.Data.SqlServerCe Namespace
SqlCeDataReader.GetName Method