Table of Contents

Class SqlConnectionDataProvider

Namespace
combit.Reporting.DataProviders
Assembly
combit.ListLabel31.CrossPlatform.SqlConnectionDataProvider.dll

Provides data access capabilities for SQL Server connections.

[Serializable]
public class SqlConnectionDataProvider : DbConnectionDataProvider, IDataProvider, ICanHandleUsedIdentifiers, IDisposable, ISupportsLogger, ISerializable
Inheritance
SqlConnectionDataProvider
Implements
Derived
Inherited Members

Examples

The following example demonstrates how to use the SqlConnectionDataProvider to export a report to PDF:

// Create a SQL Server connection using your connection string.
using SqlConnection connection = new SqlConnection("Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;");

// Create an instance of the SqlConnectionDataProvider.
SqlConnectionDataProvider provider = new SqlConnectionDataProvider(connection);

// Optional: Filter by specific schema(s).
// SqlConnectionDataProvider provider = new SqlConnectionDataProvider(connection, "dbo");

// 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 SqlConnectionDataProvider class extends DbConnectionDataProvider to provide connectivity to Microsoft SQL Server databases. It supports tables and views, schema-based filtering, advanced filtering, and automatically retrieves foreign key relationships from the database. The provider can be configured to filter tables by specific schemas and supports both single and composite primary keys. It also provides custom aggregate function mapping for SQL Server-specific functions like STDEV and VAR.

Constructors

SqlConnectionDataProvider()

Default constructor for SqlConnectionDataProvider.

protected SqlConnectionDataProvider()

SqlConnectionDataProvider(SqlConnection)

Initializes a new instance of the SqlConnectionDataProvider class.

public SqlConnectionDataProvider(SqlConnection connection)

Parameters

connection SqlConnection

The SQL Server connection.

SqlConnectionDataProvider(SqlConnection, ReadOnlyCollection<string>)

Initializes a new instance of the SqlConnectionDataProvider class with multiple table schemas.

public SqlConnectionDataProvider(SqlConnection connection, ReadOnlyCollection<string> tableSchemas)

Parameters

connection SqlConnection

The SQL Server connection.

tableSchemas ReadOnlyCollection<string>

A read-only collection of table schemas.

SqlConnectionDataProvider(SqlConnection, string)

Initializes a new instance of the SqlConnectionDataProvider class with a specific table schema.

public SqlConnectionDataProvider(SqlConnection connection, string tableSchema)

Parameters

connection SqlConnection

The SQL Server connection.

tableSchema string

The table schema to use.

SqlConnectionDataProvider(SerializationInfo, StreamingContext)

Initializes a new instance of the SqlConnectionDataProvider class from serialization data.

protected SqlConnectionDataProvider(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

The serialization information.

context StreamingContext

The streaming context.

Properties

PrefixTableNameWithSchema

Gets or sets a value indicating whether table names should be prefixed with the schema name.

public bool PrefixTableNameWithSchema { get; set; }

Property Value

bool

SupportedElementTypes

Gets or sets the supported DbConnectionElementTypes for the database connection.

public DbConnectionElementTypes SupportedElementTypes { get; set; }

Property Value

DbConnectionElementTypes

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

bool

TableSchemas

Gets a read-only collection of table schemas used by this provider.

protected ReadOnlyCollection<string> TableSchemas { get; set; }

Property Value

ReadOnlyCollection<string>

Methods

GetNativeAggregateFunctionName(NativeAggregateFunction)

Gets the native SQL Server aggregate function name for the given NativeAggregateFunction.

protected override string GetNativeAggregateFunctionName(NativeAggregateFunction functionInstance)

Parameters

functionInstance NativeAggregateFunction

The aggregate function instance.

Returns

string

The corresponding SQL Server aggregate function name.

Init()

When implemented in a derived class, initializes the data provider.

protected override void Init()

InitSqlModifications()

Initializes SQL-specific modifications such as table name validation and identifier formatting.

protected void InitSqlModifications()