Class OdbcConnectionDataProvider
- Namespace
- combit.Reporting.DataProviders
- Assembly
- combit.ListLabel31.CrossPlatform.OdbcConnectionDataProvider.dll
Provides a data provider implementation for databases accessible via ODBC connections.
[Serializable]
public sealed class OdbcConnectionDataProvider : DbConnectionDataProvider, IDataProvider, ICanHandleUsedIdentifiers, IDisposable, ISupportsLogger, ISerializable
- Inheritance
-
OdbcConnectionDataProvider
- Implements
- Inherited Members
Examples
The following example demonstrates how to use the OdbcConnectionDataProvider to export a report to PDF:
// Create an ODBC connection using a DSN or connection string.
using OdbcConnection connection = new OdbcConnection("DSN=MyDataSource;UID=user;PWD=password");
// Create an instance of the OdbcConnectionDataProvider with specified identifier delimiter and parameter marker format.
// The first parameter is the connection, second is the identifier delimiter format (e.g., "[{0}]" for SQL Server),
// and third is the parameter marker format (e.g., "@{0}" for named parameters or "?" for positional parameters).
OdbcConnectionDataProvider provider = new OdbcConnectionDataProvider(connection, "[{0}]", "?");
// Optional: Disable relation discovery for better performance if relations are not needed.
// provider.DisableRelations = true;
// 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);
Remarks
The OdbcConnectionDataProvider class extends DbConnectionDataProvider to provide connectivity to any database that supports ODBC. It retrieves schema information including tables, views, and relationships from the database using ODBC's schema discovery capabilities. The provider allows customization of identifier delimiters and parameter marker formats to support different database systems. It can optionally disable relation discovery for improved performance when only table access is needed. This provider is ideal for connecting to databases that don't have a dedicated ADO.NET provider or when using legacy database systems.
Constructors
OdbcConnectionDataProvider(OdbcConnection)
Initializes a new instance of the OdbcConnectionDataProvider class with the specified ODBC connection.
public OdbcConnectionDataProvider(OdbcConnection connection)
Parameters
connectionOdbcConnectionThe ODBC connection.
OdbcConnectionDataProvider(OdbcConnection, string, string)
Initializes a new instance of the OdbcConnectionDataProvider class with the specified ODBC connection, identifier delimiter format, and optional parameter marker format.
public OdbcConnectionDataProvider(OdbcConnection connection, string identifierDelimiterFormat, string parameterMarkerFormat = null)
Parameters
connectionOdbcConnectionThe ODBC connection.
identifierDelimiterFormatstringThe format for delimiting identifiers in SQL queries.
parameterMarkerFormatstringThe format for SQL parameter markers (optional).
Properties
IdentifierDelimiterFormat
Gets or sets the format used for delimiting identifiers in SQL queries.
public string IdentifierDelimiterFormat { get; set; }
Property Value
ParameterMarkerFormat
Gets or sets the format used for parameter markers in SQL queries.
public string ParameterMarkerFormat { get; set; }
Property Value
PrefixTableNameWithSchema
Gets or sets a value indicating whether table names should be prefixed with their schema names.
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
Init()
When implemented in a derived class, initializes the data provider.
protected override void Init()
Events
AddRelations
An event that clients can use to add relations to the data provider.
public event EventHandler<OdbcConnectionDataProvider.AddRelationEventArgs> AddRelations