To work with data via a Data Reader you must first establish a connection to the data store and specify the query to execute.Next, the Data Reader is created and acts as a bridge between the . For example, you might use code like the following: ' Establish Connection Dim my Connection as New Sql Connection(connection string) my Connection.
According to A Speed Freak's Guide to Retrieving Data in ADO.
These two objects have different roles: Data Sets are designed to be a mini-in-memory database whereas a Data Reader is designed to be a ferry of data between the database layer and a . There's the Sql Connection, Sql Command, Sql Data Adapter, and Sql Data Reader classes for working with the Sql Client provider; there's the Ole Db Connection, Ole Db Command, Ole Db Data Adapter, and Ole Db Data Reader classes for working with the Ole Db provider.
Objects that are prefixed by a provider name (Sql, Ole Db, Oracle, Odbc, etc.) are provider-specific objects.
Open() ' Create command Dim my Command as New Sql Command(SQL query or stored procedure, my Connection) ' Create a Data Reader to ferry information back from the database Dim my Reader as Sql Data Reader my Reader = my Command. End While ' Close the connection (will automatically close the reader) my Connection.
Execute Reader() 'Iterate through the results While my Reader. Close() method returns True if a row was loaded from the database, and False if there are no more rows.