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.
Ad

Recommended

DOCX
Sap ps module tutorial
achyuth10
 
PDF
Part 4 working with databases
techbed
 
PDF
Word2007p1
COLLINS CHISENGA
 
PDF
Salesforce interview-preparation-toolkit-formula-and-validation-rules-in-sale...
Amit Sharma
 
PDF
1.3 Process and Information Layout
Intan Jameel
 
PDF
Book HH- vb2008me preview
Satya Harish
 
PDF
Salesforce interview preparation toolkit formula and validation rules in sale...
Amit Sharma
 
PDF
Oracle apex hands on lab#2
Amit Sharma
 
PDF
Lab4 RTC Builds
IBM Rational software
 
PDF
Access2007
aditu_7
 
PPTX
Amazon dynamodb & amazon redshift
SumeraHangi
 
PDF
Sales force managing-data
Amit Sharma
 
DOC
Advance Java course work under NCC Education June 2011
Md. Mahbub Alam
 
PDF
ConnectSMART Tutorials
ConnectSMART
 
DOC
Advance web Design
Md. Mahbub Alam
 
PDF
E mail and-workflow-administation
Amit Sharma
 
PDF
Apex code-fundamentals
Amit Sharma
 
PPT
Ik soprovozhdenie kursy1
lasto4ka1
 
PDF
「社会問題解決×ボーダレス人材育成」の実践型教育プロジェクト MoGパートナー募集!
very50
 
PDF
металл и инновации
Ipo Board
 
PDF
IBM DB2 App Development with Microsoft Visual C#
ANIL MAHADEV
 
PDF
130124 turomisu ipoboard_webinar
Ipo Board
 
PPT
Theworldthroughoursenses 091226102905-phpapp01
kungfu panda
 
PPTX
「アジア新興国事情」 資料サンプル
very50
 
PDF
Tradematic 20022013
Ipo Board
 
PDF
Bob's world презентация для ipo board
Ipo Board
 
PDF
RAD Studio XE4 Product Reviewers Guide
ANIL MAHADEV
 
PDF
обзор рынка прямых и венчурных инвестиций 1 квартал 2015 г.
Ipo Board
 
PDF
Delphi developer certification study guide
ANIL MAHADEV
 
PPT
The wonders of nature
lasto4ka1
 

More Related Content

What's hot (9)

PDF
Lab4 RTC Builds
IBM Rational software
 
PDF
Access2007
aditu_7
 
PPTX
Amazon dynamodb & amazon redshift
SumeraHangi
 
PDF
Sales force managing-data
Amit Sharma
 
DOC
Advance Java course work under NCC Education June 2011
Md. Mahbub Alam
 
PDF
ConnectSMART Tutorials
ConnectSMART
 
DOC
Advance web Design
Md. Mahbub Alam
 
PDF
E mail and-workflow-administation
Amit Sharma
 
PDF
Apex code-fundamentals
Amit Sharma
 
Lab4 RTC Builds
IBM Rational software
 
Access2007
aditu_7
 
Amazon dynamodb & amazon redshift
SumeraHangi
 
Sales force managing-data
Amit Sharma
 
Advance Java course work under NCC Education June 2011
Md. Mahbub Alam
 
ConnectSMART Tutorials
ConnectSMART
 
Advance web Design
Md. Mahbub Alam
 
E mail and-workflow-administation
Amit Sharma
 
Apex code-fundamentals
Amit Sharma
 

Viewers also liked (16)

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

Similar to An introduction to_application_development_in_ibm_db2_udb_using_microsoft_visual_c (20)

PPTX
PATTERNS07 - Data Representation in C#
Michael Heron
 
PPS
VISUAL BASIC .net data accesss vii
argusacademy
 
PPTX
76.pptx ajx ppt file for univercity of granted
hectortrading693
 
DOCX
Simple ado program by visual studio
Aravindharamanan S
 
DOCX
Simple ado program by visual studio
Aravindharamanan S
 
PPTX
Ado.net by Awais Majeed
Awais Majeed
 
PDF
Ibm db2 10.5 for linux, unix, and windows developing ado.net and ole db app...
bupbechanhgmail
 
PDF
Database Programming With Visual Basic Net And Adonet Tips Tutorials And Code...
keeverfelmor
 
PDF
Presentation on the ADO.NET framework in C#
kittu57736
 
PPT
the .NET Framework. It provides the claf
TesfahunMaru1
 
PDF
Ado.Net Architecture
Umar Farooq
 
PPT
Ado
abhay singh
 
PPTX
Ado .net
Manish Singh
 
PPTX
PATTERNS08 - Strong Typing and Data Validation in .NET
Michael Heron
 
PPTX
Chapter 3: ado.net
Ngeam Soly
 
PPT
Database Connection
John Joseph San Juan
 
PPT
ASP.NET Session 11 12
Sisir Ghosh
 
PDF
IBM COE course book
IEC Group of Institutions
 
PPTX
For Beginners - Ado.net
Tarun Jain
 
PDF
Ado.Net
LiquidHub
 
PATTERNS07 - Data Representation in C#
Michael Heron
 
VISUAL BASIC .net data accesss vii
argusacademy
 
76.pptx ajx ppt file for univercity of granted
hectortrading693
 
Simple ado program by visual studio
Aravindharamanan S
 
Simple ado program by visual studio
Aravindharamanan S
 
Ado.net by Awais Majeed
Awais Majeed
 
Ibm db2 10.5 for linux, unix, and windows developing ado.net and ole db app...
bupbechanhgmail
 
Database Programming With Visual Basic Net And Adonet Tips Tutorials And Code...
keeverfelmor
 
Presentation on the ADO.NET framework in C#
kittu57736
 
the .NET Framework. It provides the claf
TesfahunMaru1
 
Ado.Net Architecture
Umar Farooq
 
Ado .net
Manish Singh
 
PATTERNS08 - Strong Typing and Data Validation in .NET
Michael Heron
 
Chapter 3: ado.net
Ngeam Soly
 
Database Connection
John Joseph San Juan
 
ASP.NET Session 11 12
Sisir Ghosh
 
IBM COE course book
IEC Group of Institutions
 
For Beginners - Ado.net
Tarun Jain
 
Ado.Net
LiquidHub
 
Ad

An introduction to_application_development_in_ibm_db2_udb_using_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 [email protected] 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.