Getting started
Configuring Microsoft ADO.NET data adapters to call DB2 stored procedures was a complex task prior to the introduction of the DB2 Universal Database (UDB) V8.2 Stinger technology. This tutorial walks you through the steps required to build an application that uses SQL stored procedures to select, insert, update, and delete rows from database tables and views. You will learn about the new features of the DB2 Data Adapter Configuration wizard that will allow you to not only define and manage the shape of your result set, but also define commands that invoke any language stored procedures instead of executing direct SQL.
Among the many benefits of using stored procedures instead of direct SQL from our client application is the fact that we will both optimize the execution of our application through the use of static SQL and will hide the actual schema from the client application developers. By abstracting the database schema, we allow our database architects to optimize the schema without impacting client application code.
Note:
Any of the DB2 server products may be used with this tutorial including: DB2 for z/OS V6 or later, DB2 Distributed Server V8.1 or later, and DB2 UDB for iSeries v5r1 or later, hereafter referred to as "DB2."
Why should I take this tutorial?
You should take this tutorial if you want to learn about:
- Creating new SQL stored procedures directly from the IBM Explorer.
- Configuring DB2 data adapters to use stored procedures for select, insert, update, and delete operations.
- Defining and altering the result set shape for a data adapter.
- Binding form controls to input parameters of stored procedure commands.
- Generating a data set for a stored procedure based data adapter.
- Binding form controls to a DB2-generated data set.
The tutorial was built using software from both IBM and Microsoft:
- IBM DB2 V8.2 Client or DB2 Connect, V8.2
- IBM DB2 V8.2 Application Development Client
- Any one of the following IBM DB2 servers:
- DB2 for z/OS Server V6 or later
- DB2 for iSeries V5r1 or later
- DB2 Distributed Server V8 or later
- Microsoft Windows 2000, 2003, or XP with the Microsoft .NET framework V1.1
- Microsoft Visual Studio 2002 or 2003
In the course of this tutorial, we will be creating a sample table and four stored procedures using a local or remote DB2 UDB database. If you already have a database that you can use, then you can skip this step.
To create a test database, do the following:
- Launch the Visual Studio IDE.
- Execute the View > IBM Explorer menu action to display the IBM Explorer view.
- Right click on the Data Connections folder and execute the Create New DB2 Database pop-up menu action. This will launch the Create DB2 Database dialog.
-
- Type the desired name of the local database and click OK.
Note:
You can use the DB2 Control Center to create a remote DB2 UDB database.
Now that we have created a new database or identified an existing database to use for this tutorial, we need to add the corresponding data connection to the IBM Explorer.
To add the data connection, do the following:
- Launch the Visual Studio IDE.
- Execute the View > IBM Explorer menu action to display the IBM Explorer view.
- Right click on the Data Connections folder and execute the Add Connection pop-up menu action. This will display the Add DB2 Data
Connection dialog.
- In the Connection tab, discover or specify the appropriate information required to identify your DB2 UDB connection.
- In the Filter tab, specify initial schema filters for your data connection. This is an important step as it will avoid the retrieval of unwanted catalog information.
- Click OK.
The desired data connection should now be added to your Data Connections folder in the IBM Explorer with all subfolder catalog information being retrieved and displayed asynchronously.
Note:
If you are targeting a DB2 for z/OS data connection, you must specify the z/OS SQL build options for this data connection. This can be accomplished by executing the z/OS SQL Procedure Options pop-up menu action on the z/OS data connection after it is added.




