SlideShare a Scribd company logo
An Introduction to Application Development in            IBM DB2 UDB using


                                  Microsoft Visual Studio .NET

                                           By




                                      Anil Mahadev

                         Database Technologist and Enthusiast




In this tutorial, I will dive into the nitty gritties of DB2 Application Development using
the DB2 Addin for Visual Studio.NET and build a simple Database Application using
VC# and IBM DB2 UDB.

This tutorial is a Level 100 session, which means that basic knowledge of the
products is necessary.

System Requirements:

A basic P4 Machine with 512 MB RAM and about 20 GB HDD, a pointing device,
A keyboard and a monitor.

Software Requirements

1) Windows 2000 and above.

2) A personal copy of DB2 UDB (Any edition will do, as I am still developing for test

  purposes only, I will be using the Personal Edition of DB2 UDB 8.1 for Windows.

3) Microsoft Visual Studio.NET 2003(Professional, Enterprise Developer or Enterprise
Architect).

4) Install the DB2 Addin, once you have completed the Installation of DB2 UDB.

5) Finally the urge to learn new things and adapt accordingly.
As this tutorial is going to be fully practical, attention to detail is always necessary.

If you do not understand a particular step, please go ahead and try it, until you get it
right.


So what are we waiting for, let’s develop a simple database application using the
tools mentioned above, to create an Employee Management System that views
employee details.


So lets Begin 


(Note: Hereafter I will be referring to Visual Studio.NET as VS.NET)

Firstly for those of you who have not installed the DB2 Addin for VS.NET, you can
follow these steps.
Click on Start  Programs  IBM DB2  Setup Tools  Register Visual Studio
Addins as shown in Fig 1.1




It will then open a command prompt window stating that the Addins were installed
successfully.


Now that part is done, we now need to start a new DB2 project within VS.NET.

To do that, start VS.NET from your machine and you will notice a new icon
mentioned as DB2 Tools, will be visible along with the remaining languages, you
have installed.
Now let’s give our project a sensible name, such as EmployeeApp as shown in Fig
1.2.
Next we get the following Screen by default as shown in Fig 1.3




U may notice a new toolbar appears in your IDE. This toolbar is called the IBM DB2
Toolbar. For your convenience for viewing, I have dragged the toolbar below the
form.

NOTE:

(This tool isn’t just a few icons up there; it acts as an interface between
your DB2 Client tools and your DB2 Server. You can launch the Control
center within VS.NET using this toolbar, instead of going through the
traditional way to launch it.)
We are now going to start building our Application.

Step 1:

Establish a connection to the Database using the Appropriate Connection, Data
Adapter and build our Application.

Since I have designed this tutorial for newbies, those who are just getting their
hands dirty, I shall be using the DB2 Data Adapter Control.


So let us now build our Database Connection and fetch the Employees Table from the
SAMPLE Database provided by DB2 UDB.


Now, drag and drop a DB2 Data Adapter onto your form. Next rename the
DataAdapter to db2Adp, under the properties window.


Now click on Configure Data Adapter.


We are presented with the DB2 Data Adapter Configuration Wizard as shown in Fig
1.4




Follow the instructions as given from now on.
Please remember, depending on the permissions set by your DBA, you will be able to
access the respective Database Objects.




Click on Next 

You will be presented with the following screen.




We are now going to specify the parameters for each one.

Since you have not established a connection yet. Please do so immediately.
Click on  New Connection Button  and you will be presented with the main
connection parameters dialog, where you will specify the following details

Connection Name: This is your connection name.

(Your Database Name becomes you connection name)


Database Alias: You can specify the Database you wish to connect. In this case we
shall connect to the SAMPLE Database.

User Name: This is your db2 username. (Use your credentials).

Password: This is your db2 password. (Use your credentials).




Now click on Test Connection.

You should get the following result as from the Fig 1.5
Next  Deselect all the default options as shown in Fig 1.6; since we are only going
to display data, I have another interactive tutorial in stored for that purpose.




Next we are presented with a query editor that allows us to enter custom
SQL Statements.
Since we would like the details of all Employees, please give the following query.

SELECT * FROM DATABASEARCHITECT.EMPLOYEE AS
EMPLOYEE;

Here please replace DATABASEARCHITECT with your Schema and User credentials.

The query should be like in fig 1.8




Click Next 
As you can see in Fig 1.10, the Finish screen appears with all the parameters.




Click Finish and you’re done configuring your DB2 Database to listen to your
application now.

As you will notice, two new icons will appear on the screen, they are your db2ADP
and your DB2 Connection objects.
As we all know, we need to create a Dataset. For those of you, who don’t know what
a dataset is, it is an in memory database, that stores the database related
information even after the connection is being lost from the database.


Now right click on your DataAdapter and say generate Dataset as shown in Fig 1.11
and Fig 1.12.




Rename your Dataset to DB2DS1 for simplicity.




We have now completed the task of configuring our Data Adapter, creating a Dataset
from it and successfully establishing a connection to the SAMPLE Database.
For this tutorial, I am going to place a Data Grid Control on to the Form and we are
going to display the employee records when the Form is loaded.

   1) Add a Data Grid on to the Form and Set its Dock property to Fill.


       Set its Data Source = db2DS11 and for Data Member = EMPLOYEE.

       Then set the Forms Startup Position = “Center Screen” and
       Border Style =”Fixed Single”.



       Next Open the Code window and type the following code in the Form_Load
       Event. (I shall be using C# for this tutorial);



//Fill the Data Adapter

                          db2Adp.Fill(db2DS11);

//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

        dataGrid1.SetDataBinding(db2DS11,"Employee");
Now let’s run the Application by pressing f5.

   2) And let DB2 and .NET work Magic for you as you see in Figure 1.13




Voila!!! Now wasn’t that easy.

In my next series, I shall be diving into the various powers of DB2 and .NET
combined using Stored Procedures, Triggers, the only difference will be that , I will
be developing an ASP.NET Web Application and Web Service that interact with a DB2
UDB Database.

Well folks this was a very short introduction to DB2 using .NET, hope you have found
this article fun learning, as much as I have writing it.

Please feel free to mail me your comments and valuable inputs on how I can write
better in DB2 and .NET.
You can reach me @ Anil Mahadev

                           databasearchitect@gmail.com




IBM DB2 UDB Logo          is Copyright of IBM (International Business Machines)
Corporation, USA and other International Countries where present.



Microsoft Windows and Microsoft Visual Studio.NET logo        are copyright of
Microsoft Corporation, USA and other International Countries where present.

More Related Content

DOCX
Sap ps module tutorial
PDF
Part 4 working with databases
PDF
Word2007p1
PDF
Salesforce interview-preparation-toolkit-formula-and-validation-rules-in-sale...
PDF
1.3 Process and Information Layout
PDF
Book HH- vb2008me preview
PDF
Salesforce interview preparation toolkit formula and validation rules in sale...
PDF
Oracle apex hands on lab#2
Sap ps module tutorial
Part 4 working with databases
Word2007p1
Salesforce interview-preparation-toolkit-formula-and-validation-rules-in-sale...
1.3 Process and Information Layout
Book HH- vb2008me preview
Salesforce interview preparation toolkit formula and validation rules in sale...
Oracle apex hands on lab#2

What's hot (9)

PDF
Lab4 RTC Builds
PDF
Access2007
PPTX
Amazon dynamodb & amazon redshift
PDF
Sales force managing-data
DOC
Advance Java course work under NCC Education June 2011
PDF
ConnectSMART Tutorials
DOC
Advance web Design
PDF
E mail and-workflow-administation
PDF
Apex code-fundamentals
Lab4 RTC Builds
Access2007
Amazon dynamodb & amazon redshift
Sales force managing-data
Advance Java course work under NCC Education June 2011
ConnectSMART Tutorials
Advance web Design
E mail and-workflow-administation
Apex code-fundamentals
Ad

Viewers also liked (16)

PDF
An introduction to_application_development_in_ibm_db2_udb_using_microsoft_vis...
PPT
Theworldthroughoursenses 091226102905-phpapp01
PDF
130124 turomisu ipoboard_webinar
PPTX
「アジア新興国事情」 資料サンプル
PPT
Ik soprovozhdenie kursy1
PDF
RAD Studio XE4 Product Reviewers Guide
PDF
「社会問題解決×ボーダレス人材育成」の実践型教育プロジェクト MoGパートナー募集!
PDF
Tradematic 20022013
PDF
Bob's world презентация для ipo board
PDF
обзор рынка прямых и венчурных инвестиций 1 квартал 2015 г.
PDF
металл и инновации
PDF
Delphi developer certification study guide
PDF
Sybase and ASP.NET2.0 Article
PPT
The wonders of nature
PPTX
Mission on the ground(MoG) 2012Vietnam 報告会資料
PDF
Survey on Requirements Engineering Tools
An introduction to_application_development_in_ibm_db2_udb_using_microsoft_vis...
Theworldthroughoursenses 091226102905-phpapp01
130124 turomisu ipoboard_webinar
「アジア新興国事情」 資料サンプル
Ik soprovozhdenie kursy1
RAD Studio XE4 Product Reviewers Guide
「社会問題解決×ボーダレス人材育成」の実践型教育プロジェクト MoGパートナー募集!
Tradematic 20022013
Bob's world презентация для ipo board
обзор рынка прямых и венчурных инвестиций 1 квартал 2015 г.
металл и инновации
Delphi developer certification study guide
Sybase and ASP.NET2.0 Article
The wonders of nature
Mission on the ground(MoG) 2012Vietnam 報告会資料
Survey on Requirements Engineering Tools
Ad

Similar to IBM DB2 App Development with Microsoft Visual C# (20)

PPTX
PATTERNS07 - Data Representation in C#
PPS
VISUAL BASIC .net data accesss vii
PPTX
76.pptx ajx ppt file for univercity of granted
DOCX
Simple ado program by visual studio
DOCX
Simple ado program by visual studio
PPTX
Ado.net by Awais Majeed
PDF
Ibm db2 10.5 for linux, unix, and windows developing ado.net and ole db app...
PDF
Database Programming With Visual Basic Net And Adonet Tips Tutorials And Code...
PDF
Presentation on the ADO.NET framework in C#
PPT
the .NET Framework. It provides the claf
PDF
Ado.Net Architecture
PPT
PPTX
Ado .net
PPTX
PATTERNS08 - Strong Typing and Data Validation in .NET
PDF
Database Programming with Visual Basic NET and ADO NET Tips Tutorials and Cod...
PPTX
Chapter 3: ado.net
PPT
Database Connection
PPT
ASP.NET Session 11 12
PDF
IBM COE course book
PPTX
For Beginners - Ado.net
PATTERNS07 - Data Representation in C#
VISUAL BASIC .net data accesss vii
76.pptx ajx ppt file for univercity of granted
Simple ado program by visual studio
Simple ado program by visual studio
Ado.net by Awais Majeed
Ibm db2 10.5 for linux, unix, and windows developing ado.net and ole db app...
Database Programming With Visual Basic Net And Adonet Tips Tutorials And Code...
Presentation on the ADO.NET framework in C#
the .NET Framework. It provides the claf
Ado.Net Architecture
Ado .net
PATTERNS08 - Strong Typing and Data Validation in .NET
Database Programming with Visual Basic NET and ADO NET Tips Tutorials and Cod...
Chapter 3: ado.net
Database Connection
ASP.NET Session 11 12
IBM COE course book
For Beginners - Ado.net

Recently uploaded (20)

PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Classroom Observation Tools for Teachers
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Computing-Curriculum for Schools in Ghana
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
master seminar digital applications in india
PDF
RMMM.pdf make it easy to upload and study
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Cell Structure & Organelles in detailed.
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Renaissance Architecture: A Journey from Faith to Humanism
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Classroom Observation Tools for Teachers
102 student loan defaulters named and shamed – Is someone you know on the list?
2.FourierTransform-ShortQuestionswithAnswers.pdf
Computing-Curriculum for Schools in Ghana
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
human mycosis Human fungal infections are called human mycosis..pptx
Supply Chain Operations Speaking Notes -ICLT Program
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
master seminar digital applications in india
RMMM.pdf make it easy to upload and study
GDM (1) (1).pptx small presentation for students
Cell Structure & Organelles in detailed.
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student

IBM DB2 App Development with Microsoft Visual C#

  • 1. An Introduction to Application Development in IBM DB2 UDB using Microsoft Visual Studio .NET By Anil Mahadev Database Technologist and Enthusiast In this tutorial, I will dive into the nitty gritties of DB2 Application Development using the DB2 Addin for Visual Studio.NET and build a simple Database Application using VC# and IBM DB2 UDB. This tutorial is a Level 100 session, which means that basic knowledge of the products is necessary. System Requirements: A basic P4 Machine with 512 MB RAM and about 20 GB HDD, a pointing device, A keyboard and a monitor. Software Requirements 1) Windows 2000 and above. 2) A personal copy of DB2 UDB (Any edition will do, as I am still developing for test purposes only, I will be using the Personal Edition of DB2 UDB 8.1 for Windows. 3) Microsoft Visual Studio.NET 2003(Professional, Enterprise Developer or Enterprise Architect). 4) Install the DB2 Addin, once you have completed the Installation of DB2 UDB. 5) Finally the urge to learn new things and adapt accordingly.
  • 2. As this tutorial is going to be fully practical, attention to detail is always necessary. If you do not understand a particular step, please go ahead and try it, until you get it right. So what are we waiting for, let’s develop a simple database application using the tools mentioned above, to create an Employee Management System that views employee details. So lets Begin  (Note: Hereafter I will be referring to Visual Studio.NET as VS.NET) Firstly for those of you who have not installed the DB2 Addin for VS.NET, you can follow these steps.
  • 3. Click on Start  Programs  IBM DB2  Setup Tools  Register Visual Studio Addins as shown in Fig 1.1 It will then open a command prompt window stating that the Addins were installed successfully. Now that part is done, we now need to start a new DB2 project within VS.NET. To do that, start VS.NET from your machine and you will notice a new icon mentioned as DB2 Tools, will be visible along with the remaining languages, you have installed.
  • 4. Now let’s give our project a sensible name, such as EmployeeApp as shown in Fig 1.2.
  • 5. Next we get the following Screen by default as shown in Fig 1.3 U may notice a new toolbar appears in your IDE. This toolbar is called the IBM DB2 Toolbar. For your convenience for viewing, I have dragged the toolbar below the form. NOTE: (This tool isn’t just a few icons up there; it acts as an interface between your DB2 Client tools and your DB2 Server. You can launch the Control center within VS.NET using this toolbar, instead of going through the traditional way to launch it.)
  • 6. We are now going to start building our Application. Step 1: Establish a connection to the Database using the Appropriate Connection, Data Adapter and build our Application. Since I have designed this tutorial for newbies, those who are just getting their hands dirty, I shall be using the DB2 Data Adapter Control. So let us now build our Database Connection and fetch the Employees Table from the SAMPLE Database provided by DB2 UDB. Now, drag and drop a DB2 Data Adapter onto your form. Next rename the DataAdapter to db2Adp, under the properties window. Now click on Configure Data Adapter. We are presented with the DB2 Data Adapter Configuration Wizard as shown in Fig 1.4 Follow the instructions as given from now on.
  • 7. Please remember, depending on the permissions set by your DBA, you will be able to access the respective Database Objects. Click on Next  You will be presented with the following screen. We are now going to specify the parameters for each one. Since you have not established a connection yet. Please do so immediately.
  • 8. Click on  New Connection Button  and you will be presented with the main connection parameters dialog, where you will specify the following details Connection Name: This is your connection name. (Your Database Name becomes you connection name) Database Alias: You can specify the Database you wish to connect. In this case we shall connect to the SAMPLE Database. User Name: This is your db2 username. (Use your credentials). Password: This is your db2 password. (Use your credentials). Now click on Test Connection. You should get the following result as from the Fig 1.5
  • 9. Next  Deselect all the default options as shown in Fig 1.6; since we are only going to display data, I have another interactive tutorial in stored for that purpose. Next we are presented with a query editor that allows us to enter custom SQL Statements.
  • 10. Since we would like the details of all Employees, please give the following query. SELECT * FROM DATABASEARCHITECT.EMPLOYEE AS EMPLOYEE; Here please replace DATABASEARCHITECT with your Schema and User credentials. The query should be like in fig 1.8 Click Next 
  • 11. As you can see in Fig 1.10, the Finish screen appears with all the parameters. Click Finish and you’re done configuring your DB2 Database to listen to your application now. As you will notice, two new icons will appear on the screen, they are your db2ADP and your DB2 Connection objects.
  • 12. As we all know, we need to create a Dataset. For those of you, who don’t know what a dataset is, it is an in memory database, that stores the database related information even after the connection is being lost from the database. Now right click on your DataAdapter and say generate Dataset as shown in Fig 1.11 and Fig 1.12. Rename your Dataset to DB2DS1 for simplicity. We have now completed the task of configuring our Data Adapter, creating a Dataset from it and successfully establishing a connection to the SAMPLE Database.
  • 13. For this tutorial, I am going to place a Data Grid Control on to the Form and we are going to display the employee records when the Form is loaded. 1) Add a Data Grid on to the Form and Set its Dock property to Fill. Set its Data Source = db2DS11 and for Data Member = EMPLOYEE. Then set the Forms Startup Position = “Center Screen” and Border Style =”Fixed Single”. Next Open the Code window and type the following code in the Form_Load Event. (I shall be using C# for this tutorial); //Fill the Data Adapter db2Adp.Fill(db2DS11); //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 dataGrid1.SetDataBinding(db2DS11,"Employee");
  • 14. Now let’s run the Application by pressing f5. 2) And let DB2 and .NET work Magic for you as you see in Figure 1.13 Voila!!! Now wasn’t that easy. In my next series, I shall be diving into the various powers of DB2 and .NET combined using Stored Procedures, Triggers, the only difference will be that , I will be developing an ASP.NET Web Application and Web Service that interact with a DB2 UDB Database. Well folks this was a very short introduction to DB2 using .NET, hope you have found this article fun learning, as much as I have writing it. Please feel free to mail me your comments and valuable inputs on how I can write better in DB2 and .NET.
  • 15. You can reach me @ Anil Mahadev databasearchitect@gmail.com IBM DB2 UDB Logo is Copyright of IBM (International Business Machines) Corporation, USA and other International Countries where present. Microsoft Windows and Microsoft Visual Studio.NET logo are copyright of Microsoft Corporation, USA and other International Countries where present.