DB2 Version 10.1 for Linux, UNIX, and Windows

IBM.Data.DB2 namespace

The IBM.Data.DB2 namespace contains classes that are associated with the DB2® .NET provider. You can use the classes for connecting to a database, executing commands, and retrieving results.

To use the DB2 .NET provider, you must add an imports or using statement for the IBM.Data.DB2 namespace to your application:

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

You also must include a reference to the IBM.Data.DB2.dll file in your application's project. In Visual Studio, you can include this reference by using the References section for your project in Solution Explorer or by clicking Project > Add Reference. If you are compiling a program from the command line, you can specify the IBM® .NET provider file by specifying the following option for the csc or vbc command:

/r:install_dir\bin\netfXX\IBM.Data.IBM.Data.DB2.dll

To establish a connection to one of the supported data servers, you must construct a DB2Connection object and provide it with a valid DB2 .NET connection string. For information about the supported keywords, see DB2Connection.ConnectionString property.

You require the following classes to access the data in database servers:

Classes

Class Description
public class DB2BulkCopy Facilitates the copying of rows from one data source to another.
public class DB2BulkCopyColumnMapping Represents a column mapping from the data source table to the destination table.
public class DB2BulkCopyColumnMappingCollection Represents a collection of column mappings from the data source table to the destination table.
public class DB2Command Represents an SQL statement or stored procedure to execute against a database.
public class DB2CommandBuilder Automatically generates single-table commands that are used to reconcile changes that are made to the DataSet object.
public classDB2Connection Represents an open connection to a database.
public class DB2ConnectionStringBuilder Facilitates generic and IBM Data Server Provider for .NET-specific approaches to generating valid connection strings.
public class DB2DataAdapter Represents a set of data commands and a connection to a database that are used to fill the DataSet object and update the database.
public class DB2DataReader Provides a way of reading a forward-only stream of data rows from a database.
public class DB2DataSourceEnumerator Provides a way to discover available IBM family data sources.
public class DB2Error Collects a database warning or a database error.
public class DB2ErrorCollection Collects all errors that are generated by the DB2DataAdapter object.
public class DB2Exception Represents exception that is generated when an error is returned by an IBM database server.
public class DB2Factory Represents a set of methods for creating instances of the System.Data.Common data source classes for the data provider.
public class DB2InfoMessageEventArgs Provides data for the InfoMessage event.
public classDB2Parameter Represents a parameter to a DB2Command object and, optionally, its mapping to a DataColumn object.
public classDB2ParameterCollection Represents a collection of parameters that are relevant to a DB2Command object and their mappings to columns in a DataSet object.
public class DB2Permission Enables the IBM Data Server Provider for .NET to ensure that a user has a security level that is adequate to access an IBM database.
public class DB2PermissionAttribute Associates a security action with a custom security attribute.
public class DB2Record Represents a read-only record.
public class DB2ResultSet Provides the ability to scroll through a bindable stream of rows that are returned from a database. You can also insert, update, and delete rows in the DB2ResultSet object.
public class DB2RowsCopiedEventArgs Provides data for the DB2RowsCopied event.
public class DB2RowUpdatedEventArgs Provides data for the RowUpdated event.
public class DB2RowUpdatingEventArgs Provides data for the RowUpdating event.
public class DB2Transaction Represents an SQL transaction.
public class DB2UpdatableRecord Represents a row to be created in a DB2ResultSet object.
public class DB2XmlAdapter Populates the XPathDocument object with data that is retrieved from a database.

Delegates

Delegate Description
public delegate DB2InfoMessageEventHandler Represents the method that handles the InfoMessage event from the DB2Connection object.
public delegate DB2RowsCopiedEventHandler Represents the method that handles the DB2RowsCopied event from the DB2BulkCopy object.
public delegate DB2RowUpdatedEventHandler Represents the method that handles the RowUpdated event from the DB2DataAdapter object.
public delegate DB2RowUpdatingEventHandler Represents the method that handles the RowUpdating event from the DB2DataAdapter object.

Enumerations

Enumeration Description
public enumeration DB2BulkCopyOptions Specifies options to use with the DB2BulkCopy object. The DB2BulkCopyOptions enumeration consists of bit flags, which you can combine with a bitwise operation.
public enumeration DB2CursorType Specifies cursor options to use with the DB2ResultSet object. The DB2CursorType enumeration consists of bit flags, which you can combine with a bitwise operation.
public enumerationDB2ResultSetOptions Specifies result set options to use with the DB2ResultSet object. The DB2ResultSetOptions enumeration consists of bit flags, which you can combine with a bitwise operation.
public enumeration DB2Type Specifies the data type of a field, property, or DB2Parameter object.