The first step is to drag and drop an OleDbDataAdapter component from the
toolbox's Data tab. As you drop the OleDbDataAdapter on the page. The Data
Adapter Configuration Wizard pops up on the screen. You then follow these simple
steps: At the generate the SQL Statement page, select the EmployeeID, FirstName,
LastName, Title, City, and Address fields from the Employees table, as shown in
Figure 7-30.
Generating a DataSet from Data Adapter
The next Step is to generate a data a dataset from the data adapter. To generate
a dataset from the OleDbDataAdapter, right-click on the OleDbDataAdapter, and
click the generate dataset menu option. The option brings up the Generate
Dataset page, as shown in figure 7-31. The Default name of the dataset is
DataSet1.
Figure 7-31. Generating a dataset using the data adapter's generate Dataset
option
This page actually a class called DataSet1, which comes from the DataSet class.
This class looks like figure 7-32 in Class View.
Figure 7-32. The Class View representation of the Data Set1 class
This action also adds one DataSet variable, named dataset11, to your project
(See Figure 7-33).
Figure 7-33. The data Set11 variable generated by the data adapter
You'll be using this data set11 in your application; it represents a dataset
having data from the Employees table (The SQL statement you saw in Figure 7-30).
Creating a DataView and Connecting It With a Data Set
The Next step is to connect the dataset to a data view. To do so, drop a
DataView from the toolbox's Data tab onto the page and set its Table property to
dataset11.Employee, as shown in Figure 7-34.
Figure 7-34. Setting the Table property of as data view
Dropping a data view control to the page adds a data view control named as
dataView1.
Binding a DataGrid
Now set the data grid control's DataSource property to the data view. I set
DataGrid.DataSource property to dataView1, as shown in figure 7-35.
Figure 7-35. Setting the DataGrid's DataSource property
Filling DataSet
You're almost there. Now the only thing you need to do is to call the data
adapter's Fill method and fill the dataset, and you're all set. Call the
oleDbDataAdapter1.Fill method with dataset11 as the only argument on the
Page_Load event and then call the DataGrid1.DataBind method to bind data grid
with the data. Lsting 7-5 shows how do to this.
Listing 7-5. The dataSet from DataAdapter
Now run the project, the output of the project looks like Figure 7-36.
Figure 7-36. Viewing data in a data grid using the design time data binding
method
As you can see from the previous discussion, by writing only two lines of code,
you've developed a database application.