February 21, 2019
Hot Topics:

IBM DB2 Application Development with Visual Studio .NET

  • September 18, 2006
  • By Anil Mahadev
  • Send Email »
  • More Articles »

Create a Dataset

Two new icons will appear on your screen for your db2ADP and DB2 Connection objects. Next, you need to create a Dataset, which is an in-memory database that stores the database-related information even after the connection is lost. Right click on your DataAdapter and choose generate Dataset as shown in Figure 10.

Figure 10. Right Click db2ADP and Choose Generate Dataset

Rename your Dataset to DB2DS1 for simplicity as shown in Figure 11.

Figure 11. Rename Your Dataset to DB2DS1

Add a Data Grid Control on the Form

Now, you will place a data grid control on the form so the employee records display when the form loads:
  1. Add a data grid to the form and set its Dock property to Fill. Set its Data Source to db2DS11 and its Data Member to EMPLOYEE. Then set the forms startup position to "Center Screen" and border style to "Fixed Single".
  2. Open the code window and type the following code in the Form_Load event (this tutorial uses C#):
    //Fill the Data Adapter
    //Set the Data Source of the DataGrid to the DataSet
    dataGrid1.DataSource = db2DS11;
    //Now bind the DataGrid with the Binding Option to display Employee Details from the Employee Table
  3. Run the application by pressing F5, and let DB2 and .NET work their magic for you (see Figure 12).

    Click here for a larger image.

    Figure 12. Employee Management System Results

You're Done!

Voila! Now, wasn’t that easy? You have now completed the tasks of configuring your data adapter, creating a dataset from it, establishing a connection to the SAMPLE database, and adding a data grid to the form. The result is a simple employee management system that harnesses DB2 and .NET.

About the Author

Anil Mahadev is a database technologist and enthusiast with more than three years of experience with .NET and DB2. Reach him at databasearchitect@gmail.com

Page 2 of 2

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date