Returns a DataTable that describes the column metadata of the IDataReader. Gets the 64-bit signed integer value of the specified field. Gets the 32-bit signed integer value of the specified field. Gets the 16-bit signed integer value of the specified field. Returns the GUID value of the specified field.
Gets the single-precision floating point number of the specified field. Gets the Type information corresponding to the type of Object that would be returned from GetValue(Int32). Gets the double-precision floating point number of the specified field. Gets the fixed-position numeric value of the specified field. Gets the date and time data value of the specified field. Gets the data type information for the specified field. Returns an IDataReader for the specified column ordinal. Reads a stream of characters from the specified column offset into the buffer as an array, starting at the given buffer offset. Gets the character value of the specified column. Reads a stream of bytes from the specified column offset into the buffer as an array, starting at the given buffer offset. Gets the 8-bit unsigned integer value of the specified column. Gets the value of the specified column as a Boolean. Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. Gets the number of rows changed, inserted, or deleted by execution of the SQL statement. Gets the column located at the specified index. Gets a value indicating whether the data reader is closed. Gets the number of columns in the current row. Gets a value indicating the depth of nesting for the current row. Therefore, you should mark DataReader constructors as internal. Instead, they obtain the DataReader instance through the ExecuteReader method of the Command object. Users do not create an instance of a DataReader class directly. For example, Sql is the prefix of the SqlDataAdapter class in the namespace. NET Framework data providers, name the inheriting class in the form Prv Command where Prv is the uniform prefix given to all classes in a specific. However, the precise behavior is both provider and timing dependent. For more information about DataReader classes, see Retrieving Data Using a DataReader.Īn application does not create an instance of the IDataReader interface directly, but creates an instance of a class that inherits IDataReader.Ĭlasses that inherit IDataReader must implement the inherited members, and typically define additional members to add provider-specific functionality.Ĭhanges made to a result set by another process or thread while data is being read may be visible to the user of a class that implements an IDataReader. The IDataReader and IDataRecord interfaces allow an inheriting class to implement a DataReader class, which provides a means of reading one or more forward-only streams of result sets. Private static void ReadSingleRow(IDataRecord dataRecord)Ĭonsole.WriteLine(String.Format("", record(0), record(1))) SqlDataReader reader = command.ExecuteReader() "SELECT OrderID, CustomerID FROM dbo.Orders " Private static void ReadOrderData(string connectionString) String str = "Data Source=(local) Initial Catalog=Northwind " Finally, the example closes the SqlDataReader, then the SqlConnection. The example reads through the data, writing it out to the console. The following example creates instances of the derived classes, SqlConnection, SqlCommand, and SqlDataReader.