SqlDataReader Members
Provides a way of reading a forward-only stream of rows from a SQL Server database. This class cannot be inherited.
The following tables list the members exposed by the SqlDataReader type.
(see also
Protected Properties
)
Top
| Name | Description | |
|---|---|---|
| Depth | Overridden. Gets a value that indicates the depth of nesting for the current row. |
| FieldCount | Overridden. Gets the number of columns in the current row. |
| HasRows | Overridden. Gets a value that indicates whether the SqlDataReader contains one or more rows. |
| IsClosed | Overridden. Retrieves a Boolean value that indicates whether the specified SqlDataReader instance has been closed. |
| Item | Overloaded. Overridden. Gets the value of a column in its native format. |
| RecordsAffected | Overridden. Gets the number of rows changed, inserted, or deleted by execution of the Transact-SQL statement. |
| VisibleFieldCount | Overridden. Gets the number of fields in the SqlDataReader that are not hidden. |
(see also
Protected Methods
)
Top
| Name | Description | |
|---|---|---|
| Close | Overridden. Closes the SqlDataReader object. |
| CreateObjRef | 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 | Overloaded. Releases the resources used by the DbDataReader. (Inherited from DbDataReader.) |
| Equals | Overloaded. Determines whether two Object instances are equal. (Inherited from Object.) |
| GetBoolean | Overridden. Gets the value of the specified column as a Boolean. |
| GetByte | Overridden. Gets the value of the specified column as a byte. |
| GetBytes | Overridden. Reads a stream of bytes from the specified column offset into the buffer an array starting at the given buffer offset. |
| GetChar | Overridden. Gets the value of the specified column as a single character. |
| GetChars | Overridden. Reads a stream of characters from the specified column offset into the buffer as an array starting at the given buffer offset. |
| GetData | Returns a DbDataReader object for the requested column ordinal. (Inherited from DbDataReader.) |
| GetDataTypeName | Overridden. Gets the name of the source data type. |
| GetDateTime | Overridden. Gets the value of the specified column as a DateTime object. |
| GetDecimal | Overridden. Gets the value of the specified column as a Decimal object. |
| GetDouble | Overridden. Gets the value of the specified column as a double-precision floating point number. |
| GetEnumerator | Overridden. Returns an IEnumerator that iterates through the SqlDataReader. |
| GetFieldType | Overridden. Gets the Type that is the data type of the object. |
| GetFloat | Overridden. Gets the value of the specified column as a single-precision floating point number. |
| GetGuid | Overridden. Gets the value of the specified column as a globally unique identifier (GUID). |
| GetHashCode | Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table. (Inherited from Object.) |
| GetInt16 | Overridden. Gets the value of the specified column as a 16-bit signed integer. |
| GetInt32 | Overridden. Gets the value of the specified column as a 32-bit signed integer. |
| GetInt64 | Overridden. Gets the value of the specified column as a 64-bit signed integer. |
| GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.) |
| GetName | Overridden. Gets the name of the specified column. |
| GetOrdinal | Overridden. Gets the column ordinal, given the name of the column. |
| GetProviderSpecificFieldType | Overridden. Gets an Object that is a representation of the underlying provider-specific field type. |
| GetProviderSpecificValue | Overridden. Gets an Object that is a representation of the underlying provider specific value. |
| GetProviderSpecificValues | Overridden. Gets an array of objects that are a representation of the underlying provider specific values. |
| GetSchemaTable | Overridden. Returns a DataTable that describes the column metadata of the SqlDataReader. |
| GetSqlBinary | Gets the value of the specified column as a SqlBinary. |
| GetSqlBoolean | Gets the value of the specified column as a SqlBoolean. |
| GetSqlByte | Gets the value of the specified column as a SqlByte. |
| GetSqlBytes | Gets the value of the specified column as SqlBytes. |
| GetSqlChars | Gets the value of the specified column as SqlChars. |
| GetSqlDateTime | Gets the value of the specified column as a SqlDateTime. |
| GetSqlDecimal | Gets the value of the specified column as a SqlDecimal. |
| GetSqlDouble | Gets the value of the specified column as a SqlDouble. |
| GetSqlGuid | Gets the value of the specified column as a SqlGuid. |
| GetSqlInt16 | Gets the value of the specified column as a SqlInt16. |
| GetSqlInt32 | Gets the value of the specified column as a SqlInt32. |
| GetSqlInt64 | Gets the value of the specified column as a SqlInt64. |
| GetSqlMoney | Gets the value of the specified column as a SqlMoney. |
| GetSqlSingle | Gets the value of the specified column as a SqlSingle. |
| GetSqlString | Gets the value of the specified column as a SqlString. |
| GetSqlValue | Gets an Object that is a representation of the underlying SqlDbType Variant. |
| GetSqlValues | Gets all the attribute columns in the current row. |
| GetSqlXml | Gets the value of the specified column as an XML value. |
| GetString | Overridden. Gets the value of the specified column as a string. |
| GetType | Gets the Type of the current instance. (Inherited from Object.) |
| GetValue | Overridden. Gets the value of the specified column in its native format. |
| GetValues | Overridden. Gets all attribute columns in the collection for the current row. |
| InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.) |
| IsDBNull | Overridden. Gets a value that indicates whether the column contains non-existent or missing values. |
| NextResult | Overridden. Advances the data reader to the next result, when reading the results of batch Transact-SQL statements. |
| Read | Overridden. Advances the SqlDataReader to the next record. |
| ReferenceEquals | Determines whether the specified Object instances are the same instance. (Inherited from Object.) |
| ToString | Returns a String that represents the current Object. (Inherited from Object.) |
| Name | Description | |
|---|---|---|
| Dispose | Overloaded. Releases the resources used by the DbDataReader. (Inherited from DbDataReader.) |
| Finalize | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) |
| GetDbDataReader | Returns a DbDataReader object for the requested column ordinal that can be overridden with a provider-specific implementation. (Inherited from DbDataReader.) |
| IsCommandBehavior | Determines whether the specified CommandBehavior matches that of the SqlDataReader . |
| MemberwiseClone | Overloaded. (Inherited from MarshalByRefObject.) |
| Name | Description | |
|---|---|---|
| System.Collections.IEnumerable.GetEnumerator | |
| System.Data.IDataRecord.GetData | For a description of this member, see GetData. |
| System.IDisposable.Dispose |
Item property syntax for C# (VS 2005)
In C# the Item property will not appear to work using intellisense. The problem seems to be something called an indexer property, and can be resolved using the syntax in the example below.
SqlDataReader l_reader = l_command.ExecuteReader();
string l_MyItem;
l_MyItem = l_Reader.Item("GetThis"); // Error - "System.data.SQLclient.SqlDataReader does not containg a definition for 'Item'
l_MyItem = l_Reader["GetThis"].ToString(); //Works
SqlDataReader l_reader = l_command.ExecuteReader();
string l_MyItem;
l_MyItem = l_Reader.Item("GetThis"); // Error - "System.data.SQLclient.SqlDataReader does not containg a definition for 'Item'
l_MyItem = l_Reader["GetThis"].ToString(); //Works
- 9/1/2009
- Doug S.