System.Data.OdbcClient.OdbcDataReader
)Represents a data reader for the ODBC Data Provider that reads rows from a data source.
The OdbcDataReader
provides a way to retrieve a forward-only stream of data rows from an ODBC data source.
It is optimized for performance, and you should close the reader as soon as you are finished with it.
System.Data.OdbcClient
namespace, which requires the installation of the .NET Framework Data Provider for ODBC.
public sealed class OdbcDataReader : DbDataReader, IDataRecord, IEnumerable, IEnumerable<DbDataRecord>
System.Data.Common.DbDataReader
>
System.Data.Common.DataReader
>
System.Data.Common.IDbAbstractDataReader
>
System.Data.IDataRecord
>
System.Collections.IEnumerable
>
System.Collections.Generic.IEnumerable<T>
Name | Description |
---|---|
HasRows
|
Gets a value indicating whether the data reader contains one or more rows. |
FieldCount
|
Gets the number of columns in the current row. |
Depth
|
Gets the depth of the current row in the result set. |
IsClosed
|
Gets a value indicating whether the data reader has been closed. |
Name | Description |
---|---|
GetValues(object[] values)
|
Reads a set of column values from the current row and advances the data reader to the next row. |
GetString(int ordinal)
|
Gets the value of the specified column as a string. |
GetInt32(int ordinal)
|
Gets the value of the specified column as a 32-bit signed integer. |
GetDateTime(int ordinal)
|
Gets the value of the specified column as a DateTime object. |
GetDecimal(int ordinal)
|
Gets the value of the specified column as a decimal . |
GetDouble(int ordinal)
|
Gets the value of the specified column as a double-precision floating-point number. |
GetGuid(int ordinal)
|
Gets the value of the specified column as a GUID. |
GetInt64(int ordinal)
|
Gets the value of the specified column as a 64-bit signed integer. |
GetBoolean(int ordinal)
|
Gets the value of the specified column as a boolean. |
GetByte(int ordinal)
|
Gets the value of the specified column as a byte. |
GetBytes(int ordinal, long dataOffset, byte[] buffer, int bufferOffset, int length)
|
Reads a stream of bytes from the specified column offset into the buffer as an array of bytes. |
GetChar(int ordinal)
|
Gets the value of the specified column as a character. |
GetChars(int ordinal, long dataOffset, char[] buffer, int bufferOffset, int length)
|
Reads a stream of characters from the specified column offset into the buffer as an array of characters. |
GetFloat(int ordinal)
|
Gets the value of the specified column as a single-precision floating-point number. |
GetOrdinal(string name)
|
Gets the column ordinal for the specified column name. |
GetOdbcValues(object[] values)
|
Populates an array of objects with the values of the columns of the current row. |
GetOdbcInt32(int ordinal)
|
Gets the value of the specified column as an OdbcInt32 . |
GetValue(int ordinal)
|
Gets the value of the specified column. |
GetData(int ordinal)
|
Returns an IDataRecord that represents an IDataReader . |
Read()
|
Advances the OdbcDataReader to the next record. |
Close()
|
Closes the OdbcDataReader object. |
Dispose()
|
Releases the resources used by the OdbcDataReader . |
System.Data.OdbcClient
Namespace
OdbcCommand
OdbcConnection
Close()
method when you are finished with the OdbcDataReader
to release resources. Using a using
statement is recommended for proper disposal.
public override bool HasRows { get; }
Gets a value indicating whether the data reader contains one or more rows.
public override int FieldCount { get; }
Gets the number of columns in the current row.
public override int Depth { get; }
Gets the depth of the current row in the result set. This is typically 0 for a single result set.
public override bool IsClosed { get; }
Gets a value indicating whether the data reader has been closed.
public override int GetValues(object[] values);
values
: An array of object
to copy the column values into.object
instances copied into the array.Reads a set of column values from the current row and advances the data reader to the next row.
public string GetString(int ordinal);
ordinal
: The zero-based column ordinal of the column to get.Gets the value of the specified column as a string.
public int GetInt32(int ordinal);
ordinal
: The zero-based column ordinal of the column to get.Gets the value of the specified column as a 32-bit signed integer.
public DateTime GetDateTime(int ordinal);
ordinal
: The zero-based column ordinal of the column to get.DateTime
object.
Gets the value of the specified column as a DateTime
object.
public decimal GetDecimal(int ordinal);
ordinal
: The zero-based column ordinal of the column to get.decimal
.
Gets the value of the specified column as a decimal
.
public double GetDouble(int ordinal);
ordinal
: The zero-based column ordinal of the column to get.Gets the value of the specified column as a double-precision floating-point number.
public Guid GetGuid(int ordinal);
ordinal
: The zero-based column ordinal of the column to get.Gets the value of the specified column as a GUID.
public long GetInt64(int ordinal);
ordinal
: The zero-based column ordinal of the column to get.Gets the value of the specified column as a 64-bit signed integer.
public bool GetBoolean(int ordinal);
ordinal
: The zero-based column ordinal of the column to get.Gets the value of the specified column as a boolean.
public byte GetByte(int ordinal);
ordinal
: The zero-based column ordinal of the column to get.Gets the value of the specified column as a byte.
public override long GetBytes(int ordinal, long dataOffset, byte[] buffer, int bufferOffset, int length);
ordinal
: The zero-based column ordinal of the column to read.dataOffset
: The zero-based offset in the data field from which to begin the read operation.buffer
: The buffer into which to copy the data.bufferOffset
: The zero-based offset in the buffer to begin writing data.length
: The maximum number of bytes to read.Reads a stream of bytes from the specified column offset into the buffer as an array of bytes.
public char GetChar(int ordinal);
ordinal
: The zero-based column ordinal of the column to get.Gets the value of the specified column as a character.
public override long GetChars(int ordinal, long dataOffset, char[] buffer, int bufferOffset, int length);
ordinal
: The zero-based column ordinal of the column to read.dataOffset
: The zero-based offset in the data field from which to begin the read operation.buffer
: The buffer into which to copy the data.bufferOffset
: The zero-based offset in the buffer to begin writing data.length
: The maximum number of characters to read.Reads a stream of characters from the specified column offset into the buffer as an array of characters.
public float GetFloat(int ordinal);
ordinal
: The zero-based column ordinal of the column to get.Gets the value of the specified column as a single-precision floating-point number.
public override int GetOrdinal(string name);
name
: The name of the column to find.Gets the column ordinal for the specified column name.
public int GetOdbcValues(object[] values);
values
: An array of object
to copy the column values into.object
instances copied into the array.Populates an array of objects with the values of the columns of the current row.
public OdbcInt32 GetOdbcInt32(int ordinal);
ordinal
: The zero-based column ordinal of the column to get.OdbcInt32
object representing the value of the specified column.
Gets the value of the specified column as an OdbcInt32
.
public override object GetValue(int ordinal);
ordinal
: The zero-based column ordinal of the column to get.Gets the value of the specified column.
public override IDataReader GetData(int ordinal);
ordinal
: The zero-based column ordinal of the column to retrieve.IDataRecord
that represents an IDataReader
.
Returns an IDataRecord
that represents an IDataReader
.
public override bool Read();
true
if there are more rows; otherwise, false
.
Advances the OdbcDataReader
to the next record.
public override void Close();
Closes the OdbcDataReader
object.
protected virtual void Dispose(bool disposing);
Releases the resources used by the OdbcDataReader
. This method is called by the Dispose()
method.
public void Dispose();
Releases all resources used by the ODBC Data Reader
.