OleDbDataReader Class

OleDbDataReader Class

 

Provides a way of reading a forward-only stream of data rows from a data source. This class cannot be inherited.

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

System.Object
  System.MarshalByRefObject
    System.Data.Common.DbDataReader
      System.Data.OleDb.OleDbDataReader

public sealed class OleDbDataReader : DbDataReader

NameDescription
System_CAPS_pubpropertyDepth

Gets a value that indicates the depth of nesting for the current row.(Overrides DbDataReader.Depth.)

System_CAPS_pubpropertyFieldCount

Gets the number of columns in the current row.(Overrides DbDataReader.FieldCount.)

System_CAPS_pubpropertyHasRows

Gets a value that indicates whether the OleDbDataReader contains one or more rows.(Overrides DbDataReader.HasRows.)

System_CAPS_pubpropertyIsClosed

Indicates whether the data reader is closed.(Overrides DbDataReader.IsClosed.)

System_CAPS_pubpropertyItem[Int32]

Gets the value of the specified column in its native format given the column ordinal.(Overrides DbDataReader.Item[Int32].)

System_CAPS_pubpropertyItem[String]

Gets the value of the specified column in its native format given the column name.(Overrides DbDataReader.Item[String].)

System_CAPS_pubpropertyRecordsAffected

Gets the number of rows changed, inserted, or deleted by execution of the SQL statement.(Overrides DbDataReader.RecordsAffected.)

System_CAPS_pubpropertyVisibleFieldCount

Gets the number of fields in the OleDbDataReader that are not hidden.(Overrides DbDataReader.VisibleFieldCount.)

NameDescription
System_CAPS_pubmethodClose()

Closes the OleDbDataReader object.(Overrides DbDataReader.Close().)

System_CAPS_pubmethodCreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodDispose()

Releases all resources used by the current instance of the DbDataReader class.(Inherited from DbDataReader.)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetBoolean(Int32)

Gets the value of the specified column as a Boolean.(Overrides DbDataReader.GetBoolean(Int32).)

System_CAPS_pubmethodGetByte(Int32)

Gets the value of the specified column as a byte.(Overrides DbDataReader.GetByte(Int32).)

System_CAPS_pubmethodGetBytes(Int32, Int64, Byte[], Int32, Int32)

Reads a stream of bytes from the specified column offset into the buffer as an array starting at the given buffer offset.(Overrides DbDataReader.GetBytes(Int32, Int64, Byte[], Int32, Int32).)

System_CAPS_pubmethodGetChar(Int32)

Gets the value of the specified column as a character.(Overrides DbDataReader.GetChar(Int32).)

System_CAPS_pubmethodGetChars(Int32, Int64, Char[], Int32, Int32)

Reads a stream of characters from the specified column offset into the buffer as an array starting at the given buffer offset.(Overrides DbDataReader.GetChars(Int32, Int64, Char[], Int32, Int32).)

System_CAPS_pubmethodGetData(Int32)

Returns an OleDbDataReader object for the requested column ordinal.

System_CAPS_pubmethodGetDataTypeName(Int32)

Gets the name of the source data type.(Overrides DbDataReader.GetDataTypeName(Int32).)

System_CAPS_pubmethodGetDateTime(Int32)

Gets the value of the specified column as a DateTime object.(Overrides DbDataReader.GetDateTime(Int32).)

System_CAPS_pubmethodGetDecimal(Int32)

Gets the value of the specified column as a Decimal object.(Overrides DbDataReader.GetDecimal(Int32).)

System_CAPS_pubmethodGetDouble(Int32)

Gets the value of the specified column as a double-precision floating-point number.(Overrides DbDataReader.GetDouble(Int32).)

System_CAPS_pubmethodGetEnumerator()

Returns an IEnumerator that can be used to iterate through the rows in the data reader.(Overrides DbDataReader.GetEnumerator().)

System_CAPS_pubmethodGetFieldType(Int32)

Gets the Type that is the data type of the object.(Overrides DbDataReader.GetFieldType(Int32).)

System_CAPS_pubmethodGetFieldValue<T>(Int32)

Synchronously gets the value of the specified column as a type.(Inherited from DbDataReader.)

System_CAPS_pubmethodGetFieldValueAsync<T>(Int32)

Asynchronously gets the value of the specified column as a type.(Inherited from DbDataReader.)

System_CAPS_pubmethodGetFieldValueAsync<T>(Int32, CancellationToken)

Asynchronously gets the value of the specified column as a type.(Inherited from DbDataReader.)

System_CAPS_pubmethodGetFloat(Int32)

Gets the value of the specified column as a single-precision floating-point number.(Overrides DbDataReader.GetFloat(Int32).)

System_CAPS_pubmethodGetGuid(Int32)

Gets the value of the specified column as a globally unique identifier (GUID).(Overrides DbDataReader.GetGuid(Int32).)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetInt16(Int32)

Gets the value of the specified column as a 16-bit signed integer.(Overrides DbDataReader.GetInt16(Int32).)

System_CAPS_pubmethodGetInt32(Int32)

Gets the value of the specified column as a 32-bit signed integer.(Overrides DbDataReader.GetInt32(Int32).)

System_CAPS_pubmethodGetInt64(Int32)

Gets the value of the specified column as a 64-bit signed integer.(Overrides DbDataReader.GetInt64(Int32).)

System_CAPS_pubmethodGetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodGetName(Int32)

Gets the name of the specified column.(Overrides DbDataReader.GetName(Int32).)

System_CAPS_pubmethodGetOrdinal(String)

Gets the column ordinal, given the name of the column.(Overrides DbDataReader.GetOrdinal(String).)

System_CAPS_pubmethodGetProviderSpecificFieldType(Int32)

Returns the provider-specific field type of the specified column.(Inherited from DbDataReader.)

System_CAPS_pubmethodGetProviderSpecificValue(Int32)

Gets the value of the specified column as an instance of Object.(Inherited from DbDataReader.)

System_CAPS_pubmethodGetProviderSpecificValues(Object[])

Gets all provider-specific attribute columns in the collection for the current row.(Inherited from DbDataReader.)

System_CAPS_pubmethodGetSchemaTable()

Returns a DataTable that describes the column metadata of the OleDbDataReader.(Overrides DbDataReader.GetSchemaTable().)

System_CAPS_pubmethodGetStream(Int32)

Retrieves data as a Stream.(Inherited from DbDataReader.)

System_CAPS_pubmethodGetString(Int32)

Gets the value of the specified column as a string.(Overrides DbDataReader.GetString(Int32).)

System_CAPS_pubmethodGetTextReader(Int32)

Retrieves data as a TextReader.(Inherited from DbDataReader.)

System_CAPS_pubmethodGetTimeSpan(Int32)

Gets the value of the specified column as a TimeSpan object.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodGetValue(Int32)

Gets the value of the column at the specified ordinal in its native format.(Overrides DbDataReader.GetValue(Int32).)

System_CAPS_pubmethodGetValues(Object[])

Populates an array of objects with the column values of the current row.(Overrides DbDataReader.GetValues(Object[]).)

System_CAPS_pubmethodInitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodIsDBNull(Int32)

Gets a value that indicates whether the column contains nonexistent or missing values.(Overrides DbDataReader.IsDBNull(Int32).)

System_CAPS_pubmethodIsDBNullAsync(Int32)

An asynchronous version of IsDBNull, which gets a value that indicates whether the column contains non-existent or missing values.(Inherited from DbDataReader.)

System_CAPS_pubmethodIsDBNullAsync(Int32, CancellationToken)

An asynchronous version of IsDBNull, which gets a value that indicates whether the column contains non-existent or missing values. Optionally, sends a notification that operations should be cancelled.(Inherited from DbDataReader.)

System_CAPS_pubmethodNextResult()

Advances the data reader to the next result, when reading the results of batch SQL statements.(Overrides DbDataReader.NextResult().)

System_CAPS_pubmethodNextResultAsync()

An asynchronous version of NextResult, which advances the reader to the next result when reading the results of a batch of statements.

Invokes NextResultAsync with CancellationToken.None.(Inherited from DbDataReader.)

System_CAPS_pubmethodNextResultAsync(CancellationToken)

This is the asynchronous version of NextResult. Providers should override with an appropriate implementation. The cancellationToken may optionally be ignored.

The default implementation invokes the synchronous NextResult method and returns a completed task, blocking the calling thread. The default implementation will return a cancelled task if passed an already cancelled cancellationToken. Exceptions thrown by NextResult will be communicated via the returned Task Exception property.

Other methods and properties of the DbDataReader object should not be invoked while the returned Task is not yet completed.(Inherited from DbDataReader.)

System_CAPS_pubmethodRead()

Advances the OleDbDataReader to the next record.(Overrides DbDataReader.Read().)

System_CAPS_pubmethodReadAsync()

An asynchronous version of Read, which advances the reader to the next record in a result set. This method invokes ReadAsync with CancellationToken.None.(Inherited from DbDataReader.)

System_CAPS_pubmethodReadAsync(CancellationToken)

This is the asynchronous version of Read. Providers should override with an appropriate implementation. The cancellationToken may optionally be ignored.

The default implementation invokes the synchronous Read method and returns a completed task, blocking the calling thread. The default implementation will return a cancelled task if passed an already cancelled cancellationToken. Exceptions thrown by Read will be communicated via the returned Task Exception property.

Do not invoke other methods and properties of the DbDataReader object until the returned Task is complete.(Inherited from DbDataReader.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIDataRecord.GetData(Int32)

For a description of this member, see IDataRecord.GetData.(Inherited from DbDataReader.)

NameDescription
System_CAPS_pubmethodAsParallel()

Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)

System_CAPS_pubmethodAsQueryable()

Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.)

System_CAPS_pubmethodCast<TResult>()

Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.)

System_CAPS_pubmethodOfType<TResult>()

Filters the elements of an IEnumerable based on a specified type.(Defined by Enumerable.)

To create an OleDbDataReader, you must call the ExecuteReader method of the OleDbCommand object, instead of directly using a constructor.

Before you close the OleDbConnection, first close the OleDbDataReader object. You must also close the OleDbDataReader object if you plan to resuse an OleDbCommand object.For example, you cannot retrieve output parameters until after you call Close.

Changes made to a result set by another process or thread while data is being read may be visible to the user of the OleDbDataReader. However, the precise behavior is timing dependent.

IsClosed and RecordsAffected are the only properties that you can call after the OleDbDataReader is closed. Although the RecordsAffected property may be accessed while the OleDbDataReader exists, always call Close before returning the value of RecordsAffected to guarantee an accurate return value.

The following example creates an OleDbConnection, an OleDbCommand, and an OleDbDataReader. The example reads through the data, writing it out to the console. Finally, the example closes the OleDbDataReader and then the OleDbConnection.

public static void ReadData(string connectionString, string queryString)
{
    using (OleDbConnection connection = new OleDbConnection(connectionString))
    {
        OleDbCommand command = new OleDbCommand(queryString, connection);

        connection.Open();
        OleDbDataReader reader = command.ExecuteReader();

        while (reader.Read())
        {
            Console.WriteLine(reader[0].ToString());
        }
        reader.Close();
    }
}

.NET Framework
Available since 1.1

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

System.Data.OleDb Namespace
Working with DataReaders

Return to top
Show:
© 2016 Microsoft