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
'Usage
Dim instance As SqlCeDataReader
Dim name As String
Dim returnValue As Integer
returnValue = instance.GetOrdinal(name)
public override int GetOrdinal(
string name
)
public:
virtual int GetOrdinal(
String^ name
) override
abstract GetOrdinal :
name:string -> int
override GetOrdinal :
name:string -> int
public override function GetOrdinal(
name : String
) : int
Parameters
- name
Type: System. . :: . .String
The name of the column.
Return Value
Type: System. . :: . .Int32
The zero-based column ordinal.
Implements
IDataRecord. . :: . .GetOrdinal(String)
Exceptions
Exception | 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.