This is the ADO.Net equivalent of the ADO RecordSet.
Once you populate a DataReader with the contents from a table you cannot navigate from the end to the beginning.
Forward only stream
Doesn't allow you to sort, filter or page through the data.
The DataReader remains connected to the data source.
This object provides a forward-only / read-only / connected stream recordset from a database
DataReader objects cannot be directly instantiated rather this object is returned as a result from the Command objects ExecuteReader method.

The DataReader can return data directly to the application when you do not need it to be cached in memory.

Because only one row is in memory as any one time, this provides the lowest overhead in terms of system performance however it does require the exclusive use of an open connection.
You cannot update the database by means of the DataReader

Dim objCommand As OleDb.OleDbCommand 
Dim gDataReader As System.Data.OleDb.OleDbDataReader

objCommand = New OleDb.OleDbCommand("SELECT * FROM TableName", objDataConnection)
objDataReader = objCommand.ExecuteReader()

While objDataReader.Read()
End While

The DataReader class yields better performance than the DataSet class for forward only browsing.


DepthReturns the depth of nesting of the current row.
FieldCountReturns the number of columns in the current row.
IsClosedReturns True if the DataReader is closed.
ItemReturns the value of the column with the specified index or name.
RecordsAffectedReturns the number of rows inserted, deleted or updated by the SQL statement.


ReadAdvances to the next row and returns True if there are more rows. False when at the end of the resultset.
CloseCloses the DataReader and released all the resources. Makes the connection available for other commands.
GetBoolean*Retrieves the strongly types value of the field at the specified column index.
GetBytesFills a Byte array (or a prtion thereof) with the contents of a binary field; returns the number of bytes read.
GetCharsFills a Char array (or a portion therof) with the contents of a long text field; returns the number of characters read.
GetDataTypeNameReturns the name of the source data type for the column whose index is passed as an argument.
GetFieldTypeReturns the System.Type object that describes the type of the field at the given index.
GetNameReturns the name of the column with the specified index.
GetOrdinalReturns the index of a column corresponding to the field name passed as an argument.
GetSchemaTableReturns a DataTable that describes the column metadata.
GetValueReturns the value of a column at the specified index in its native format.
GetValuesTakes an Object array and fills it with the values from all the columns in the resultset; returns the number of Objects in the array.
IsDBNullReturns True if the column at the specified index contains a DBNull value.
NextResultAdvances to the next resultset and returns True if there is another resultset. Use this to process multiple resultsets.

© 2020 Better Solutions Limited. All Rights Reserved. © 2020 Better Solutions Limited TopPrevNext