Skip to main content
A newer version of this page is available. .

IConnectionProviderService.LoadConnection(String) Method

Loads the specified SqlDataConnection.

Namespace: DevExpress.DataAccess.Wizard.Services

Assembly: DevExpress.DataAccess.v18.2.dll

Declaration

SqlDataConnection LoadConnection(
    string connectionName
)

Parameters

Name Type Description
connectionName String

A String value, specifying the connection name.

Returns

Type Description
SqlDataConnection

An SqlDataConnection object.

Remarks

The following code illustrates an IConnectionProviderService implementation.


using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Sql;
using DevExpress.DataAccess.Wizard.Services;
// ...

public class CustomConnectionProviderService : IConnectionProviderService {
    public SqlDataConnection LoadConnection(string connectionName) {
        // Specify custom connection parameters.
        return new SqlDataConnection(connectionName, 
            new MsSqlConnectionParameters("localhost", "dataBaseName", "userName", "password", MsSqlAuthorizationType.Windows));
    }
}

The following code adds a custom connection provider service to the XtraReport.PrintingSystem property before previewing the report.


using DevExpress.DataAccess.Wizard.Services;
using DevExpress.XtraReports.UI;
// ...

XtraReport report = new XtraReport();
report.LoadLayout("XtraReport1.repx");
report.PrintingSystem.AddService(typeof(IConnectionProviderService), new CustomConnectionProviderService());
ReportPrintTool pt = new ReportPrintTool(report);
pt.ShowPreviewDialog();

The IConnectionProviderService.LoadConnection method will be invoked for each connection that was serialized into the report definition file. Using the connectionName parameter, you can specify necessary connection parameters and return a required SqlDataConnection object.

See Also