System.Data.OleDb.OleDbDataReader
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()
DropDownList1.Items.Add(objDataReader.GetString(0)
End While
The DataReader class yields better performance than the DataSet class for forward only browsing.
Properties
Depth | Returns the depth of nesting of the current row. |
FieldCount | Returns the number of columns in the current row. |
IsClosed | Returns True if the DataReader is closed. |
Item | Returns the value of the column with the specified index or name. |
RecordsAffected | Returns the number of rows inserted, deleted or updated by the SQL statement. |
Methods
Read | Advances to the next row and returns True if there are more rows. False when at the end of the resultset. |
Close | Closes 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. |
GetBytes | Fills a Byte array (or a prtion thereof) with the contents of a binary field; returns the number of bytes read. |
GetChars | Fills a Char array (or a portion therof) with the contents of a long text field; returns the number of characters read. |
GetDataTypeName | Returns the name of the source data type for the column whose index is passed as an argument. |
GetFieldType | Returns the System.Type object that describes the type of the field at the given index. |
GetName | Returns the name of the column with the specified index. |
GetOrdinal | Returns the index of a column corresponding to the field name passed as an argument. |
GetSchemaTable | Returns a DataTable that describes the column metadata. |
GetValue | Returns the value of a column at the specified index in its native format. |
GetValues | Takes an Object array and fills it with the values from all the columns in the resultset; returns the number of Objects in the array. |
IsDBNull | Returns True if the column at the specified index contains a DBNull value. |
NextResult | Advances to the next resultset and returns True if there is another resultset. Use this to process multiple resultsets. |
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext