OleDbDataReader Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides a way of reading a forward-only stream of data rows from a data source. This class cannot be inherited.
public ref class OleDbDataReader sealed : System::Data::Common::DbDataReader
public ref class OleDbDataReader sealed : MarshalByRefObject, IDisposable, System::Collections::IEnumerable, System::Data::IDataReader
public sealed class OleDbDataReader : System.Data.Common.DbDataReader
public sealed class OleDbDataReader : MarshalByRefObject, IDisposable, System.Collections.IEnumerable, System.Data.IDataReader
type OleDbDataReader = class
inherit DbDataReader
type OleDbDataReader = class
inherit MarshalByRefObject
interface IDataReader
interface IDisposable
interface IDataRecord
interface IEnumerable
Public NotInheritable Class OleDbDataReader
Inherits DbDataReader
Public NotInheritable Class OleDbDataReader
Inherits MarshalByRefObject
Implements IDataReader, IDisposable, IEnumerable
- Inheritance
- Inheritance
- Inheritance
- Implements
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();
}
}
Public Sub ReadData(ByVal connectionString As String, _
ByVal queryString As String)
Using connection As New OleDbConnection(connectionString)
Dim command As New OleDbCommand(queryString, connection)
connection.Open()
Dim reader As OleDbDataReader = command.ExecuteReader()
While reader.Read()
Console.WriteLine(reader(0).ToString())
End While
reader.Close()
End Using
End Sub
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.
Depth |
Gets a value that indicates the depth of nesting for the current row. |
Field |
Gets the number of columns in the current row. |
Has |
Gets a value that indicates whether the OleDbDataReader contains one or more rows. |
Is |
Indicates whether the data reader is closed. |
Item[Int32] |
Gets the value of the specified column in its native format given the column ordinal. |
Item[String] |
Gets the value of the specified column in its native format given the column name. |
Records |
Gets the number of rows changed, inserted, or deleted by execution of the SQL statement. |
Visible |
Gets the number of fields in the OleDbDataReader that are not hidden. |
Close() |
Closes the OleDbDataReader object. |
Close |
Asynchronously closes the DbDataReader object. (Inherited from DbDataReader) |
Create |
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject) |
Dispose() |
Releases all resources used by the current instance of the DbDataReader class. (Inherited from DbDataReader) |
Dispose(Boolean) |
Releases the unmanaged resources used by the DbDataReader and optionally releases the managed resources. (Inherited from DbDataReader) |
Dispose |
Asynchronously releases all resources used by the current instance of the DbDataReader class. (Inherited from DbDataReader) |
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
Finalize() |
Allows the object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. |
Get |
Gets the value of the specified column as a Boolean. |
Get |
Gets the value of the specified column as a byte. |
Get |
Reads a stream of bytes from the specified column offset into the buffer as an array starting at the given buffer offset. |
Get |
Gets the value of the specified column as a character. |
Get |
Reads a stream of characters from the specified column offset into the buffer as an array starting at the given buffer offset. |
Get |
This is the asynchronous version of GetColumnSchema(DbDataReader).
Providers should override with an appropriate implementation.
The |
Get |
Returns an OleDbDataReader object for the requested column ordinal. |
Get |
Gets the name of the source data type. |
Get |
Gets the value of the specified column as a DateTime object. |
Get |
Returns a DbDataReader object for the requested column ordinal that can be overridden with a provider-specific implementation. (Inherited from DbDataReader) |
Get |
Gets the value of the specified column as a Decimal object. |
Get |
Gets the value of the specified column as a double-precision floating-point number. |
Get |
Returns an IEnumerator that can be used to iterate through the rows in the data reader. |
Get |
Gets the Type that is the data type of the object. |
Get |
Gets the value of the specified column as the requested type. (Inherited from DbDataReader) |
Get |
Asynchronously gets the value of the specified column as the requested type. (Inherited from DbDataReader) |
Get |
Asynchronously gets the value of the specified column as the requested type. (Inherited from DbDataReader) |
Get |
Gets the value of the specified column as a single-precision floating-point number. |
Get |
Gets the value of the specified column as a globally unique identifier (GUID). |
Get |
Serves as the default hash function. (Inherited from Object) |
Get |
Gets the value of the specified column as a 16-bit signed integer. |
Get |
Gets the value of the specified column as a 32-bit signed integer. |
Get |
Gets the value of the specified column as a 64-bit signed integer. |
Get |
Obsolete.
Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject) |
Get |
Gets the name of the specified column. |
Get |
Gets the column ordinal, given the name of the column. |
Get |
Gets the provider-specific type of the specified column. (Inherited from DbDataReader) |
Get |
Gets the value of the specified column as an instance of a provider-specific type. (Inherited from DbDataReader) |
Get |
Gets all provider-specific attribute columns in the collection for the current row. (Inherited from DbDataReader) |
Get |
Returns a DataTable that describes the column metadata of the OleDbDataReader. |
Get |
This is the asynchronous version of GetSchemaTable().
Providers should override with an appropriate implementation.
The |
Get |
Gets a stream to retrieve data from the specified column. (Inherited from DbDataReader) |
Get |
Gets the value of the specified column as a string. |
Get |
Gets a text reader to retrieve data from the column. (Inherited from DbDataReader) |
Get |
Gets the value of the specified column as a TimeSpan object. |
Get |
Gets the Type of the current instance. (Inherited from Object) |
Get |
Gets the value of the column at the specified ordinal in its native format. |
Get |
Populates an array of objects with the column values of the current row. |
Initialize |
Obsolete.
Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject) |
Is |
Gets a value that indicates whether the column contains nonexistent or missing values. |
Is |
Asynchronously gets a value that indicates whether the column contains non-existent or missing values. (Inherited from DbDataReader) |
Is |
Asynchronously gets a value that indicates whether the column contains non-existent or missing values. (Inherited from DbDataReader) |
Memberwise |
Creates a shallow copy of the current Object. (Inherited from Object) |
Memberwise |
Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject) |
Next |
Advances the data reader to the next result, when reading the results of batch SQL statements. |
Next |
Asynchronously advances the reader to the next result when reading the results of a batch of statements. (Inherited from DbDataReader) |
Next |
Asynchronously advances the reader to the next result when reading the results of a batch of statements. (Inherited from DbDataReader) |
Read() |
Advances the OleDbDataReader to the next record. |
Read |
Asynchronously advances the reader to the next record in a result set. (Inherited from DbDataReader) |
Read |
Asynchronously advances the reader to the next record in a result set. (Inherited from DbDataReader) |
To |
Returns a string that represents the current object. (Inherited from Object) |
IData |
Returns an IDataReader for the specified column ordinal. |
IData |
For a description of this member, see GetData(Int32). (Inherited from DbDataReader) |
IDisposable. |
This API supports the product infrastructure and is not intended to be used directly from your code. Releases the resources used by the current instance of the OleDbDataReader class. |
IEnumerable. |
Returns an enumerator that iterates through a collection. |
Can |
Gets a value that indicates whether a DbDataReader can get a column schema. |
Get |
Gets the column schema (DbColumn collection) for a DbDataReader. |
Cast<TResult>(IEnumerable) |
Casts the elements of an IEnumerable to the specified type. |
Of |
Filters the elements of an IEnumerable based on a specified type. |
As |
Enables parallelization of a query. |
As |
Converts an IEnumerable to an IQueryable. |
Prodotto | Versioni |
---|---|
.NET | 8 (package-provided), 9 (package-provided) |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
Feedback su .NET
.NET è un progetto di open source. Selezionare un collegamento per fornire feedback: