dotConnect for DB2 supports working with both strongly typed and untyped DataSets. The DataSet Editor is a tool that allows you to create a strongly typed DataSet visually. This tutorial shows how to set the DataSet schema with the editor manually. For information about typed DataSet generation with the help of wizard, see tutorial Using DataSet Wizard.
This walkthrough supposes that you know how to establish the connection to the DB2 server (see Logging onto the Server) and how to use Devart configuration window for data tables and commands.
In this tutorial, we will create a strongly typed DataSet from an untyped one. It will include tables Dept and Emp; for their definitions, see the tables.sql script which is located in the dotConnect for DB2 installation directory. The following steps need to be performed:
Create an untyped DataSet DB2DataSet1. To do this, you may either drop an DB2DataSet object to the form or double-click it in the toolbox. Select the Untyped DB2DataSet option and click OK:
Double-click new DataSet or select the Edit item from the pop-up menu to start DataSet Editor.
Create a data table. Use the Add new table to DataSet button to create a new data table. Rename the table to "Dept" with the corresponding item of the pop-up menu.
Configure data table. Set up DataTable select and update commands. Double-click the table or select the Configure Data Table item from the pop-up menu. DataTable Editor window will appear:
For detailed information about DataTable Editor using, see the Working with Command Editor topic.
Generate data table schema. Populate the Columns collection of the data table by clicking the Create Columns item from the table item pop-up menu:
Otherwise, you will be prompted to create table columns during the DataSet schema saving.
Configure additional data tables. Repeat steps 2-4 to add other data tables (the only Emp table in our case):
Note:To remove redundant data tables from your DataSet, use the Remove table from the DataSet button.
Create associations. Use the Edit DataSet relations button to set up associations between your tables. Add and edit relations in the relation editor:
Save DataSet Schema. Use the Save Schema button to save your DataSet. Set the schema name to NewDataSet. After schema saving the NewDataSet class is generated. It will be available in the toolbox and can be used for other typed DataSets creation with the same schema. DB2DataSet1 object becomes an instance of typed NewDataSet and cannot be changed by the editor anymore:
The DB2DataSet1 object can be used as common typed DataSet now. For example, the following code will
Working with Command Editor | Using DataSet Wizard | Logging Onto The Server