Class MySqlDataReader
Provides a means of reading a forward-only stream of rows from a MySQL database. This class cannot be inherited.
Inheritance
Implements
Namespace: MySql.Data.MySqlClient
Assembly: MySql.Data.dll
Version: 9.3.0
Syntax
public sealed class MySqlDataReader : DbDataReader, IEnumerable, IAsyncDisposable, IDataReader, IDataRecord, IDisposable
Remarks
To create a My
While the My
Is
For optimal performance, My
Properties
Depth
Gets a value indicating the depth of nesting for the current row. This method is not supported currently and always returns 0.
Declaration
public override int Depth { get; }
Property Value
Type | Description |
---|---|
System. |
The depth of nesting for the current row. |
Overrides
FieldCount
Gets the number of columns in the current row.
Declaration
public override int FieldCount { get; }
Property Value
Type | Description |
---|---|
System. |
The number of columns in the current row. |
Overrides
HasRows
Gets a value indicating whether the My
Declaration
public override bool HasRows { get; }
Property Value
Type | Description |
---|---|
System. |
true if the My |
Overrides
IsClosed
Gets a value indicating whether the data reader is closed.
Declaration
public override bool IsClosed { get; }
Property Value
Type | Description |
---|---|
System. |
true if the My |
Overrides
Item[Int32]
Overloaded. Gets the value of a column in its native format.
In C#, this property is the indexer for the My
Declaration
public override object this[int i] { get; }
Parameters
Type | Name | Description |
---|---|---|
System. |
i |
Property Value
Type | Description |
---|---|
System. |
The value of the specified column. |
Overrides
Item[String]
Gets the value of a column in its native format.
[C#] In C#, this property is the indexer for the My
Declaration
public override object this[string name] { get; }
Parameters
Type | Name | Description |
---|---|---|
System. |
name |
Property Value
Type | Description |
---|---|
System. |
The value of the specified column. |
Overrides
RecordsAffected
Gets the number of rows changed, inserted, or deleted by execution of the SQL statement.
Declaration
public override int RecordsAffected { get; }
Property Value
Type | Description |
---|---|
System. |
The number of rows changed, inserted, or deleted. -1 for SELECT statements; 0 if no rows were affected or the statement failed. |
Overrides
Methods
Close()
Closes the My
Declaration
public override void Close()
Overrides
CloseAsync()
Asynchronously closes the My
Declaration
public override Task CloseAsync()
Returns
Type | Description |
---|---|
System. |
A task representing the asynchronous operation. |
Overrides
Dispose(Boolean)
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System. |
disposing |
Overrides
DisposeAsync()
Releases all resources used by the current instance of the My
Declaration
public override ValueTask DisposeAsync()
Returns
Type | Description |
---|---|
System. |
Overrides
Finalize()
Declaration
protected void Finalize()
GetBodyDefinition(String)
Gets the body definition of a routine.
Declaration
public string GetBodyDefinition(string column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The column name. |
Returns
Type | Description |
---|---|
System. |
The definition of the routine. |
GetBoolean(Int32)
Gets the value of the specified column as a Boolean.
Declaration
public override bool GetBoolean(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Overrides
GetBoolean(String)
Gets the value of the specified column as a Boolean.
Declaration
public bool GetBoolean(string name)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | The column name. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
GetByte(Int32)
Gets the value of the specified column as a byte.
Declaration
public override byte GetByte(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Overrides
GetByte(String)
Gets the value of the specified column as a byte.
Declaration
public byte GetByte(string name)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | The column name. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
GetBytes(Int32, Int64, Byte[], Int32, Int32)
Reads a stream of bytes from the specified column offset into the buffer an array starting at the given buffer offset.
Declaration
public override long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal. |
System. |
fieldOffset | The index within the field from which to begin the read operation. |
System. |
buffer | The buffer into which to read the stream of bytes. |
System. |
bufferoffset | The index for buffer to begin the read operation. |
System. |
length | The maximum length to copy into the buffer. |
Returns
Type | Description |
---|---|
System. |
The actual number of bytes read. |
Overrides
GetChar(Int32)
Gets the value of the specified column as a single character.
Declaration
public override char GetChar(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Overrides
GetChar(String)
Gets the value of the specified column as a single character.
Declaration
public char GetChar(string name)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | The column name. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
GetChars(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.
Declaration
public override long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal. |
System. |
fieldoffset | The index within the row from which to begin the read operation. |
System. |
buffer | The buffer into which to copy the data. |
System. |
bufferoffset | The index with the buffer to which the data will be copied. |
System. |
length | The maximum number of characters to read. |
Returns
Type | Description |
---|---|
System. |
The actual number of characters read. |
Overrides
GetDataTypeName(Int32)
Gets the name of the source data type.
Declaration
public override string GetDataTypeName(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
A string representing the name of the data type. |
Overrides
GetDateTime(Int32)
Gets the value of the specified column as a System.
Declaration
public override DateTime GetDateTime(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Overrides
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
note
MySql allows date columns to contain the value '0000-00-00' and datetime
columns to contain the value '0000-00-00 00:00:00'. The DateTime structure cannot contain
or represent these values. To read a datetime value from a column that might
contain zero values, use Get
The behavior of reading a zero datetime column using this method is defined by the
ZeroDateTimeBehavior connection string option. For more information on this option,
please refer to Connection
GetDateTime(String)
Gets the value of the specified column as a System.
Declaration
public DateTime GetDateTime(string column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The column name. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
note
MySql allows date columns to contain the value '0000-00-00' and datetime
columns to contain the value '0000-00-00 00:00:00'. The DateTime structure cannot contain
or represent these values. To read a datetime value from a column that might
contain zero values, use Get
The behavior of reading a zero datetime column using this method is defined by the
ZeroDateTimeBehavior connection string option. For more information on this option,
please refer to Connection
GetDecimal(Int32)
Gets the value of the specified column as a System.
Declaration
public override decimal GetDecimal(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Overrides
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetDecimal(String)
Gets the value of the specified column as a System.
Declaration
public decimal GetDecimal(string column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The column name. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetDouble(Int32)
Gets the value of the specified column as a double-precision floating point number.
Declaration
public override double GetDouble(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Overrides
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetDouble(String)
Gets the value of the specified column as a double-precision floating point number.
Declaration
public double GetDouble(string column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The column name. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetEnumerator()
Returns an System.
Declaration
public override IEnumerator GetEnumerator()
Returns
Type | Description |
---|---|
System. |
An System. |
Overrides
GetFieldType(Int32)
Gets the Type that is the data type of the object.
Declaration
public override Type GetFieldType(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
The data type of the specified column. |
Overrides
GetFieldType(String)
Gets the Type that is the data type of the object.
Declaration
public Type GetFieldType(string column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The column name. |
Returns
Type | Description |
---|---|
System. |
The data type of the specified column. |
GetFieldValue<T>(Int32)
Gets the value of the specified column as a type.
Declaration
public override T GetFieldValue<T>(int ordinal)
Parameters
Type | Name | Description |
---|---|---|
System. |
ordinal | The index of the column. |
Returns
Type | Description |
---|---|
T | The value of the column. |
Type Parameters
Name | Description |
---|---|
T | Type. |
Overrides
GetFloat(Int32)
Gets the value of the specified column as a single-precision floating point number.
Declaration
public override float GetFloat(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Overrides
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetFloat(String)
Gets the value of the specified column as a single-precision floating point number.
Declaration
public float GetFloat(string column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The column name. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetGuid(Int32)
Gets the value of the specified column as a globally-unique identifier(GUID).
Declaration
public override Guid GetGuid(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Overrides
GetGuid(String)
Gets the value of the specified column as a globally-unique identifier(GUID).
Declaration
public Guid GetGuid(string column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The name of the column. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
GetInt16(Int32)
Gets the value of the specified column as a 16-bit signed integer.
Declaration
public override short GetInt16(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Overrides
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetInt16(String)
Gets the value of the specified column as a 16-bit signed integer.
Declaration
public short GetInt16(string column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The column name. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetInt32(Int32)
Gets the value of the specified column as a 32-bit signed integer.
Declaration
public override int GetInt32(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Overrides
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetInt32(String)
Gets the value of the specified column as a 32-bit signed integer.
Declaration
public int GetInt32(string column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The column name. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetInt64(Int32)
Gets the value of the specified column as a 64-bit signed integer.
Declaration
public override long GetInt64(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Overrides
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetInt64(String)
Gets the value of the specified column as a 64-bit signed integer.
Declaration
public long GetInt64(string column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The column name. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetMySqlDateTime(Int32)
Gets the value of the specified column as a My
Declaration
public MySqlDateTime GetMySqlDateTime(int column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
My |
The value of the specified column. |
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call IsDBNull to check for null values before calling this method.
GetMySqlDateTime(String)
Gets the value of the specified column as a My
Declaration
public MySqlDateTime GetMySqlDateTime(string column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The column name. |
Returns
Type | Description |
---|---|
My |
The value of the specified column. |
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call IsDBNull to check for null values before calling this method.
GetMySqlDecimal(Int32)
Gets the value of the specified column as a My
Declaration
public MySqlDecimal GetMySqlDecimal(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The index of the colum. |
Returns
Type | Description |
---|---|
My |
The value of the specified column as a My |
GetMySqlDecimal(String)
Gets the value of the specified column as a My
Declaration
public MySqlDecimal GetMySqlDecimal(string column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The name of the colum. |
Returns
Type | Description |
---|---|
My |
The value of the specified column as a My |
GetMySqlGeometry(Int32)
Gets the value of the specified column as a My
Declaration
public MySqlGeometry GetMySqlGeometry(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The index of the colum. |
Returns
Type | Description |
---|---|
My |
The value of the specified column as a My |
GetMySqlGeometry(String)
Gets the value of the specified column as a My
Declaration
public MySqlGeometry GetMySqlGeometry(string column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The name of the colum. |
Returns
Type | Description |
---|---|
My |
The value of the specified column as a My |
GetName(Int32)
Gets the name of the specified column.
Declaration
public override string GetName(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
The name of the specified column. |
Overrides
GetOrdinal(String)
Gets the column ordinal, given the name of the column.
Declaration
public override int GetOrdinal(string name)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | The name of the column. |
Returns
Type | Description |
---|---|
System. |
The zero-based column ordinal. |
Overrides
GetSByte(Int32)
Gets the value of the specified column as a sbyte.
Declaration
public sbyte GetSByte(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
GetSByte(String)
Gets the value of the specified column as a sbyte.
Declaration
public sbyte GetSByte(string name)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | The column name. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
GetSchemaTable()
Describes the column metadata of the My
Declaration
public override DataTable GetSchemaTable()
Returns
Type | Description |
---|---|
System. |
A System. |
Overrides
GetStream(Int32)
Gets a stream to retrieve data from the specified column.
Declaration
public override Stream GetStream(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
A stream |
Overrides
GetString(Int32)
Gets the value of the specified column as a System.
Declaration
public override string GetString(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Overrides
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetString(String)
Gets the value of the specified column as a System.
Declaration
public string GetString(string column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The column name. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetTimeSpan(Int32)
Gets the value of the specified column as a System.
Declaration
public TimeSpan GetTimeSpan(int column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetTimeSpan(String)
Gets the value of the specified column as a System.
Declaration
public TimeSpan GetTimeSpan(string column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The column name. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetUInt16(Int32)
Gets the value of the specified column as a 16-bit unsigned integer.
Declaration
public ushort GetUInt16(int column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetUInt16(String)
Gets the value of the specified column as a 16-bit unsigned integer.
Declaration
public ushort GetUInt16(string column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The column name. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetUInt32(Int32)
Gets the value of the specified column as a 32-bit unsigned integer.
Declaration
public uint GetUInt32(int column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetUInt32(String)
Gets the value of the specified column as a 32-bit unsigned integer.
Declaration
public uint GetUInt32(string column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The column name. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetUInt64(Int32)
Gets the value of the specified column as a 64-bit unsigned integer.
Declaration
public ulong GetUInt64(int column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetUInt64(String)
Gets the value of the specified column as a 64-bit unsigned integer.
Declaration
public ulong GetUInt64(string column)
Parameters
Type | Name | Description |
---|---|---|
System. |
column | The column name. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Remarks
No conversions are performed; therefore, the data retrieved must already be a System.
Call Is
GetValue(Int32)
Gets the value of the specified column in its native format.
Declaration
public override object GetValue(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
The value of the specified column. |
Overrides
GetValues(Object[])
Gets all attribute columns in the collection for the current row.
Declaration
public override int GetValues(object[] values)
Parameters
Type | Name | Description |
---|---|---|
System. |
values | An array of System. |
Returns
Type | Description |
---|---|
System. |
The number of instances of System. |
Overrides
IsDBNull(Int32)
Gets a value indicating whether the column contains non-existent or missing values.
Declaration
public override bool IsDBNull(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
true if the specified column is equivalent to System. |
Overrides
NextResult()
Advances the data reader to the next result when reading the results of batch SQL statements.
Declaration
public override bool NextResult()
Returns
Type | Description |
---|---|
System. |
true if there are more result sets; otherwise false. |
Overrides
NextResultAsync(CancellationToken)
Declaration
public override Task<bool> NextResultAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System. |
cancellationToken |
Returns
Type | Description |
---|---|
System. |
Overrides
Read()
Advances the My
Declaration
public override bool Read()
Returns
Type | Description |
---|---|
System. |
true if there are more rows; otherwise false. |
Overrides
ReadAsync(CancellationToken)
Declaration
public override Task<bool> ReadAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System. |
cancellationToken |
Returns
Type | Description |
---|---|
System. |
Overrides
Explicit Interface Implementations
IDataRecord.GetData(Int32)
Returns a System.
Declaration
IDataReader IDataRecord.GetData(int i)
Parameters
Type | Name | Description |
---|---|---|
System. |
i | The zero-based column ordinal. |
Returns
Type | Description |
---|---|
System. |
A System. |