Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DataTableReader::GetValue Method (Int32)

 

Gets the value of the specified column in its native format.

Namespace:   System.Data
Assembly:  System.Data (in System.Data.dll)

public:
virtual Object^ GetValue(
	int ordinal
) override

Parameters

ordinal
Type: System::Int32

The zero-based column ordinal

Return Value

Type: System::Object^

The value of the specified column. This method returns DBNull for null columns.

Exception Condition
ArgumentOutOfRangeException

The index passed was outside the range of 0 to FieldCount - 1.

DeletedRowInaccessibleException

An attempt was made to retrieve data from a deleted row.

InvalidOperationException

An attempt was made to read or access columns in a closed DataTableReader .

Although you can call IsDBNull to see if there are null values before calling this method, you do not have to do this.

The following example iterates through all the columns within the current row in a DataTableReader, displaying the contents of each column and the column name. Generally, if your intent is to work with all the columns within a row retrieved by a DataTableReader, consider using the GetValues method instead, because it is more efficient.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show:
© 2017 Microsoft