Overview of developing ADO.NET applications using the DB2 Everyplace

.NET Data Provider

The namespaces for the DB2 Everyplace .NET Data Provider are as follows:

The DB2 Everyplace .NET Data Provider provides functionality for connecting to a DB2 Everyplace data source, 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 data source.

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

DB2 Everyplace .NET Data Provider classes inherit or implement members from other .NET Framework classes or interfaces. This provider documentation includes a summary of the supported 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.

Prerequisite

ǥ 6. Prerequisites for using the DB2 Everyplace

.NET Data Provider
Component Minimum requirement
Microsoft.NET Framework

Microsoft.NET Framework 1.0

Must be installed prior to installing the DB2 Everyplace .NET Data Provider for application development

Microsoft Visual Studio.NET 2003 Microsoft Visual Studio.NET 2003 for developing mobile applications
Microsoft.NET Compact Framework

Microsoft .NET Compact Framework 1.0 for mobile development

Must be installed on the device prior to installing the DB2 Everyplace .NET Data Provider for mobile application development.

DB2 Everyplace product
  • DB2e.dll of version 8.1.4 or above
  • AgentProxy.dll
    
    of version 8.1.4 or above required for remoted stored procedure call
  • wbxmllib.dll of version 8.1.4 or above required for remoted stored procedure call.
  • DB2 Everyplace Sync Server version 8.1.4 or above required for remoted stored procedure call

DB2e.dll, AgentProxy.dll, and wbxmllib.dll are native libraries and thus are processor dependent; thus, the operating system needs to locate these native libraries (setting the environment variable PATH, for example) in order for DB2 Everyplace .NET Data Provider to function properly.

Restrictions

Provider Limitations

Thread Safety

Any public non-instance members of this provider are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.

Procedure

There are four core objects that make up DB2 Everyplace .NET data provider. The following table describes these objects and their function.

ǥ 7. DB2 Everyplace .NET Data Provider, core objects

Object Desciption
DB2eConnection Establishes a connection to a DB2 Everyplace data source and can begin a Transaction.
DB2eCommand Executes a command at a DB2 Everyplace server, and exposes Parameters.
DB2eDataAdapter Populates a DataSet and resolves updates with the DB2 Everyplace data source.
DB2eDataReader Exposes and reads a forward-only stream of data from a DB2 Everyplace data source.

Along with the core classes listed in the preceding table, the DB2 .NET data provider also contains the classes listed in the following table.

ǥ 8. DB2 Everyplace .NET Data Provider, additional classes

Object Desciption
DB2eCommandBuilder A helper object that will automatically generate command properties of the DB2eDataAdapter or will derive parameter information from a stored procedure and populate the DB2eParameters collection of a DB2eCommand object. Note: Use of the DB2eCommandBuilder is not recommended as it can generate very inefficient and, in some cases, invalid SQL statements.
DB2eError Exposes the information from a warning or error returned by a DB2 Everyplace data source.
DB2eException Returned when an error is encountered at the DB2 Everyplace data source. For an error encountered at the client, .NET data providers throw a .NET Framework exception.
DB2eParameter Defines input, output, and return value parameters for commands and stored procedures.
DB2eTransaction Enables you to enlist commands in transactions at the DB2 Everyplace data source.

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

[Visual Basic]
Imports IBM.Data.DB2.DB2e

[C#]
using IBM.Data.DB2.DB2e;

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

csc /r:IBM.Data.DB2.DB2e.dll

For the .NET Compact Framework, the namespace is IBM.Data.DB2.DB2e.CF, and the application needs to reference the IBM.Data.DB2.DB2e.CF.dll assembly.

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

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

ǥ 9. Classes

Object Desciption
DB2eCommand Represents an SQL statement or stored procedure to execute against a data source. This class cannot be inherited.
DB2eCommandBuilder Automatically generates single-table commands used to reconcile changes made to a DataSet with the associated data source. This class cannot be inherited.
DB2eConnection Represents an open connection to a data source.
DB2eDataAdapter Represents a set of data commands and a connection to a data source that are used to fill the DataSet and update the data source. This class cannot be inherited.
DB2eDataReader Provides a way of reading a forward-only stream of data rows from a data source. This class cannot be inherited.
DB2eError Collects information relevant to a warning or error returned by the data source. This class cannot be inherited.
DB2eException The exception that is generated when a warning or error is returned by a DB2 Everyplace data source. This class cannot be inherited.
DB2eParameter Represents a parameter to a DB2eCommand and optionally, its mapping to a DataColumn. This class cannot be inherited.
DB2eTransaction Represents an SQL transaction to be made at a data source. This class cannot be inherited.

ǥ 10. Delegates

Delegate Desciption
DB2eInfoMessageEventHandler Represents the method that will handle the InfoMessage event of a DB2eConnection.
DB2eRowUpdatedEventHandler Represents the method that will handle the RowUpdated event of a DB2eDataAdapter.
DB2eRowUpdatingEventHandler Represents the method that will handle the RowUpdating event of an DB2eDataAdapter.

ǥ 11. Enumerations

Enumeration Desciption
DB2eType Specifies the data type of a field, property, or DB2eParameter.

ǥ 12. DB2 Everyplace .NET Provider Connection String Keywords

Keyword Desciption
Database Database location. For example: C:\data1\
UID User ID
PWD Password

C# Example

string connString = @"Database=C:\data1\; UID=user; PWD=userpwd";

Related concepts

Related tasks