IConnectionProviderService Interface
If implemented, enables you to restore a data connection on deserializing a report.
Namespace: DevExpress.DataAccess.Wizard.Services
Assembly: DevExpress.DataAccess.v19.2.dll
Declaration
Related API Members
The following members return IConnectionProviderService objects:
Remarks
You can use the IConnectionProviderService
interface to restore the data connections of a report and its child DetailReportBand objects.
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.