Class DB2ConnectionDataProvider
- Namespace
- combit.Reporting.DataProviders
- Assembly
- combit.ListLabel31.CrossPlatform.dll
Provider for DB2, see https://www.ibm.com/support/pages/download-initial-version-115-clients-and-drivers. Tested with version 10.5.
[Serializable]
public sealed class DB2ConnectionDataProvider : DbConnectionDataProvider, IDataProvider, ICanHandleUsedIdentifiers, IDisposable, ISupportsLogger, ISerializable
- Inheritance
-
DB2ConnectionDataProvider
- Implements
- Inherited Members
Examples
The following example demonstrates how to use the DB2ConnectionDataProvider to export a report to PDF:
// Example 1: Basic connection with connection string
DB2ConnectionDataProvider provider = new DB2ConnectionDataProvider(
"Server=myDB2Server:50000;Database=SAMPLE;UID=myuser;PWD=mypassword;");
// Create a ListLabel reporting engine instance and assign the provider as the data source.
using ListLabel listLabel = new ListLabel();
listLabel.DataSource = provider;
// Configure export settings to generate a PDF.
ExportConfiguration exportConfiguration = new ExportConfiguration(LlExportTarget.Pdf, exportFilePath, projectFilePath);
exportConfiguration.ShowResult = true;
// Export the report to PDF.
listLabel.Export(exportConfiguration);
// Example 2: Connection with specific schema filtering
DB2ConnectionDataProvider schemaProvider = new DB2ConnectionDataProvider(
"Server=myDB2Server:50000;Database=SAMPLE;UID=myuser;PWD=mypassword;",
"MYSCHEMA");
// Example 3: Connection with multiple schemas
List<string> schemas = new List<string> { "SCHEMA1", "SCHEMA2", "SCHEMA3" };
DB2ConnectionDataProvider multiSchemaProvider = new DB2ConnectionDataProvider(
"Server=myDB2Server:50000;Database=SAMPLE;UID=myuser;PWD=mypassword;",
schemas.AsReadOnly());
// Example 4: Configure table name prefixing with schema
DB2ConnectionDataProvider prefixedProvider = new DB2ConnectionDataProvider(
"Server=myDB2Server:50000;Database=SAMPLE;UID=myuser;PWD=mypassword;");
prefixedProvider.PrefixTableNameWithSchema = true;
// Example 5: Filter to only tables (exclude views)
DB2ConnectionDataProvider tablesOnlyProvider = new DB2ConnectionDataProvider(
"Server=myDB2Server:50000;Database=SAMPLE;UID=myuser;PWD=mypassword;");
tablesOnlyProvider.SupportedElementTypes = DbConnectionElementTypes.Table;
Remarks
The DB2ConnectionDataProvider class extends DbConnectionDataProvider to provide connectivity to IBM DB2 databases using the IBM.Data.DB2 ADO.NET provider. It supports tables and views with schema-based filtering, automatically retrieves foreign key relationships, and handles composite primary keys. The provider queries DB2's system catalog tables (SYSCAT) to discover database metadata and relationships. It supports custom filter syntax translation for List & Label expressions, converting them to DB2-compatible SQL syntax. Schema filtering allows limiting data access to specific database schemas, excluding system schemas by default (SYSTOOLS, SYSIBM, SYSCAT, SYSSTAT, SYSIBMADM). The provider provides native aggregate function mapping for DB2-specific functions.
Constructors
DB2ConnectionDataProvider(string)
Initializes a new instance of the DB2ConnectionDataProvider class using the specified connection string.
public DB2ConnectionDataProvider(string connectionString)
Parameters
connectionStringstringThe connection string for the DB2 database.
DB2ConnectionDataProvider(string, ReadOnlyCollection<string>)
Initializes a new instance of the DB2ConnectionDataProvider class using the specified connection string and table schemas.
public DB2ConnectionDataProvider(string connectionString, ReadOnlyCollection<string> tableSchemas)
Parameters
connectionStringstringThe connection string for the DB2 database.
tableSchemasReadOnlyCollection<string>A read-only collection of table schemas to include.
DB2ConnectionDataProvider(string, string)
Initializes a new instance of the DB2ConnectionDataProvider class using the specified connection string and a single table schema.
public DB2ConnectionDataProvider(string connectionString, string tableSchema)
Parameters
connectionStringstringThe connection string for the DB2 database.
tableSchemastringThe table schema to include.
Properties
PrefixTableNameWithSchema
Gets or sets a value indicating whether to prefix table names with their schema.
public bool PrefixTableNameWithSchema { get; set; }
Property Value
SupportedElementTypes
Gets or sets the supported DbConnectionElementTypes for the database connection.
public DbConnectionElementTypes SupportedElementTypes { get; set; }
Property Value
Remarks
This property indicates which element types (tables, views) are supported by this data provider.
SupportsAdvancedFiltering
Gets or sets a value indicating whether advanced filtering is supported by the data provider.
public override bool SupportsAdvancedFiltering { get; set; }
Property Value
Methods
GetNativeAggregateFunctionName(NativeAggregateFunction)
Gets the native aggregate function name for the specified aggregate function.
protected override string GetNativeAggregateFunctionName(NativeAggregateFunction functionInstance)
Parameters
functionInstanceNativeAggregateFunctionThe native aggregate function.
Returns
- string
The corresponding DB2 aggregate function name.
Init()
Initializes the data provider by retrieving table and relation metadata from the DB2 database.
protected override void Init()
OnTranslateFilterSyntax(object, TranslateFilterSyntaxEventArgs)
Raises the TranslateFilterSyntax event.
protected override void OnTranslateFilterSyntax(object sender, TranslateFilterSyntaxEventArgs e)
Parameters
senderobjectThe source of the event.
eTranslateFilterSyntaxEventArgsA TranslateFilterSyntaxEventArgs that contains the event data.