This tutorial is part of Database Programming Made Easy Series.
Dataset can be either connected to or disconnected from data sources. Data is save back to the database by using Data Adapters. Data Adapters handles the connection between Data Sources and Dataset
Remember that in the previous topic we discuss the use of Data Readers. One rule is not to use dataset if you only need to retrieve data.
In Visual Basic 6.0 you always use a connected ADO connection. Unlike with Dataset where you can process the data in an offline mode. This will eliminate redundancy of creating a new connection every time you request a data.
Note that the purpose of this tutorial is to teach you the use of Datasets and Data Adapters. I will not discuss in details all the features of Dataset.
Now let us try this example. We will populate a Dataset with a Data Adapter. We’re still using the previous code but with few modification.
In Dataset you do not need to create a command like
because Data Adapter will do that for you automatically. This is one of the features that a Dataset has.
The codes that you need to familiarize with, in using Datasets:
1. Datasets and Data Adapters – Microsoft Access
2. Datasets and Data Adapters – Microsoft SQL Server
How it works:
First we create a new instance of Data Adapter
followed by a Dataset
and we access the data using the Data Table
with its row properties
Another important feature of a Dataset is its ability to pull the entire schema of a data table including its relationship.
Next topic we will discuss on how to save data back to the database.
Previous: How to Retrieve Data Using Data Reader Next: How to Modify Data