Using a DataSet to Read and Modify Data

In the previous chapter, we showed how to read data from a database using a DataReader object. Here we show how to read data using a DataSet object. The difference here is that the DataSet object is populated with data from the database and then used for managing the data. The DataSet object keeps track of any changes made to the data in the DataSet. The DataSet modifications can be saved back to the database at any point.

When reading data into a DataSet, the idea is to use a DataAdapter object to fill the DataSet. The DataAdapter uses a Connection object and a query string (SQL statement) for retrieving the desired rows from the database. After the DataSet is populated with data, the database connection ...

Get Visual Basic® .NET by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.