Microsoft.NET

……………………………………………….Expertise in .NET Technologies

DB2 .NET Data Provider

Posted by Ravi Varma Thumati on October 8, 2009

The DB2 .NET Data Provider extends DB2 support for the ADO.NET interface. The DB2 .NET Data Provider delivers high-performing, secure access to DB2 data.

The DB2 .NET Data Provider allows your .NET applications to access the following database management systems:

  • DB2 Universal Database Version 8 for Windows, UNIX, and Linux-based computers
  • DB2 Universal Database Version 6 (or later) for OS/390 and z/OS, through DB2 Connect
  • DB2 Universal Database Version 5, Release 1 (or later) for AS/400 and iSeries, through DB2 Connect
  • DB2 Universal Database Version 7.3 (or later) for VSE & VM, through DB2 Connect

In addition to the DB2 .NET Data Provider, there is also a collection of add-ins to the Microsoft Visual Studio .NET IDE. These add-ins simplify the creation of DB2 applications that use the ADO.NET interface. You can also use these add-ins to develop server-side objects, such as SQL stored procedures and user-defined functions.

System Requirements for the DB2 .NET Data Provider

Before using the DB2 Install program to install the DB2 .NET Data Provider, you must already have the .NET Framework (Version 1.0 or Version 1.1) installed on the computer. If the .NET Framework is not installed, the DB2 Install program will not install the DB2 .NET Data Provider.

For DB2 Universal Database for AS/400 and iSeries, the following fix is required on the server: APAR ii13348.

Only the .NET Framework Version 1.1 and Visual Studio .NET 2003 are supported for use with DB2 for VSE & VM, and DB2 for iSeries servers. The .NET Framework Version 1.0 and Visual Studio .NET 2002 are not supported for use with these servers.

Using the DB2 .NET Data Provider Documentation

The DB2 .NET Data Provider reference documentation contains detailed provider-specific information. Many of the DB2 .NET Data Provider classes inherit or implement members from other .NET Framework classes or interfaces. The provider documentation includes a summary of all members within each of these classes. For more detailed information about a specific inherited member, see the appropriate topic in the Microsoft(R) .NET Framework SDK.

Developing DB2 .NET Data Provider Applications

The IBM.Data.DB2 namespace contains the DB2 .NET Data Provider.

The DB2 .NET Data Provider provides functionality for connecting to a database, executing commands, and retrieving results. Those results can be processed directly, or placed in an ADO.NET DataSet for further processing while in a disconnected state. While in the DataSet, data can be exposed to the user, combined with other data from multiple sources, or passed remotely between tiers. Any processing performed on the data while in the DataSet can then be reconciled to the database.

The DB2 .NET Data Provider is designed to be lightweight. It consists of a minimal layer between the database and your code. This extends functionality without sacrificing performance.

There are four core objects that make up the DB2 .NET Data Provider. The following table describes those objects and their function.

Object Description
DB2Connection Establishes a connection to a specific database and can begin a Transaction.
DB2Command Executes a command at a database, and exposes Parameters.
DB2DataReader Exposes and reads a forward-only stream of data from a database.
DB2DataAdapter Populates a DataSet and resolves updates with the data source.

Along with the core classes listed in the preceding table, .NET data providers also contain the classes listed in the following table.

Object Description
ClientPermission Provided for .NET data provider code access security attributes.
CommandBuilder A helper object that will automatically generate command properties of a DataAdapter or will derive parameter information from a stored procedure and populate the Parameters collection of a Command object.
Error Exposes the information from a warning or error returned by a data source.
Exception Returned when an error is encountered at the database. For an error encountered at the client, .NET data providers throw a .NET Framework exception.
Parameter Defines input, output, and return value parameters for commands and stored procedures.
Transaction Enables you to enlist commands in transactions at the database.

To use the DB2 .NET Data Provider, you must add an imports or using statement for the IBM.Data.DB2 namespace to your application .DLL, as the following code illustrates:

 [Visual Basic]
Imports IBM.Data.DB2
[C#]
using IBM.Data.DB2;

You also must include a reference to the .DLL when you compile your code. For example, if you are compiling a C# program, your command line should include:

csc /r:%DB2PATH%\bin\netf11\IBM.Data.DB2.dll

To establish a connection to one of the supported DB2 Universal Database systems, you will need to construct a DB2Connection object and provide it with a valid DB2 .NET connection string. See the DB2Connection.ConnectionString property for information on the supported keywords.

For detailed information about how to best use the IBM.Data.DB2 namespace, see the documentation on the following DB2 .NET Data Provider classes:

For more information about how the DB2 .NET Data Provider functions within the .NET Framework, see IBM.Data.DB2 Hierarchy.

Classes

Class Description
DB2Command Represents an SQL statement or stored procedure to execute against a database. This class cannot be inherited.
DB2CommandBuilder Automatically generates single-table commands used to reconcile changes made to a DataSet with the associated database. This class cannot be inherited.
DB2Connection Represents an open connection to a database.
DB2DataAdapter Represents a set of data commands and a connection to a database that are used to fill the DataSet and update the database. This class cannot be inherited.
DB2DataReader Provides a way of reading a forward-only stream of data rows from a database. This class cannot be inherited.
DB2Error Collects information relevant to a warning or error returned by the database. This class cannot be inherited.
DB2ErrorCollection Collects all errors generated by the DB2DataAdapter. This class cannot be inherited.
DB2Exception The exception that is generated when an error is returned by a DB2 database. This class cannot be inherited.
DB2InfoMessageEventArgs Provides data for the InfoMessage event. This class cannot be inherited.
DB2Parameter Represents a parameter to a DB2Command and optionally, its mapping to a DataColumn. This class cannot be inherited.
DB2ParameterCollection Represents a collection of parameters relevant to a DB2Command as well as their respective mappings to columns in a DataSet. This class cannot be inherited.
DB2Permission Enables the DB2 .NET Data Provider to ensure that a user has a security level adequate to access a DB2 database. This class cannot be inherited.
DB2PermissionAttribute Associates a security action with a custom security attribute.
DB2RowUpdatedEventArgs Provides data for the RowUpdated event. This class cannot be inherited.
DB2RowUpdatingEventArgs Provides data for the RowUpdating event. This class cannot be inherited.
DB2Transaction Represents an SQL transaction to be made at a database. This class cannot be inherited.

Delegates

Delegate Description
DB2InfoMessageEventHandler Represents the method that will handle the InfoMessage event of a DB2Connection.
DB2RowUpdatedEventHandler Represents the method that will handle the RowUpdated event of a DB2DataAdapter.
DB2RowUpdatingEventHandler Represents the method that will handle the RowUpdating event of a DB2DataAdapter.

Enumerations

Enumeration Description
DB2Type Specifies the data type of a field, property, or DB2Parameter.

DB2 .NET Data Provider

The DB2(R) .NET Data Provider extends DB2 support for the ADO.NET interface. The DB2 .NET Data Provider delivers high-performing, secure access to DB2 data.

The DB2 .NET Data Provider allows your .NET applications to access the following database management systems:

  • DB2 Universal Database(TM) Version 8 for Windows(R), UNIX(R), and Linux-based computers
  • DB2 Universal Database Version 6 (or later) for OS/390(R) and z/OS(TM), through DB2 Connect(TM)
  • DB2 Universal Database Version 5, Release 1 (or later) for AS/400(R) and iSeries(TM), through DB2 Connect
  • DB2 Universal Database Version 7.3 (or later) for VSE & VM, through DB2 Connect

To develop and run applications that use DB2 .NET Data Provider you need the .NET Framework, Version 1.0 or 1.1.

In addition to the DB2 .NET Data Provider, there is also a collection of add-ins to the Microsoft(R) Visual Studio .NET IDE. This add-ins simplifies the creation of DB2 applications that use the ADO.NET interface. You can also use this add-ins to develop server-side objects, such as SQL stored procedures and user-defined functions.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: