Implementing a Connection Class for a Data Processing Extension
The Connection object represents a database connection or similar resource and is the starting point for users of a SQL Server Reporting Services data processing extension. It represents connections to database servers, though any entity with similar behavior can be exposed as a Connection.
To implement a Connection object, create a class that implements T:Microsoft.ReportingServices.DataProcessing.IDbConnection and optionally implements T:Microsoft.ReportingServices.DataProcessing.IDbConnectionExtension.
In your implementation, you must ensure that a connection is created and opened before commands can be executed. Ensure that your implementation requires clients to open and close connections explicitly, rather than having your implementation open and close connections implicitly for the client. Perform your security checks when the connection is obtained. Requiring an existing connection for the other classes in your SSRS data processing extension will then ensure that security checks are always performed when working with your data source.
The properties of the desired connection are represented as a connection string. It is strongly recommended that SSRS data processing extensions support the P:Microsoft.ReportingServices.DataProcessing.IDbConnection.ConnectionString property using the familiar name/value pair system defined by OLE DB.
Connection objects are often resource-intensive to obtain, so you may want to consider pooling connections or other techniques to mitigate this.
T:Microsoft.ReportingServices.DataProcessing.IDbConnection inherits from T:Microsoft.ReportingServices.Interfaces.IExtension. You must implement the T:Microsoft.ReportingServices.Interfaces.IExtension interface as part of your connection class implementation. The T:Microsoft.ReportingServices.Interfaces.IExtension interface enables a class to implement a localized extension name and to process extension-specific configuration information stored in the Reporting Services configuration file.
Your Connection object contains the P:Microsoft.ReportingServices.Interfaces.IExtension.LocalizedName property through its implementation of T:Microsoft.ReportingServices.Interfaces.IExtension. It is strongly recommended that Reporting Services data processing extensions support the P:Microsoft.ReportingServices.Interfaces.IExtension.LocalizedName property, so that users encounter a familiar, localized name for the extension in a user interface, such as Report Manager.
T:Microsoft.ReportingServices.Interfaces.IExtension also enables your Connection object to retrieve and process custom configuration data stored in the RSReportServer.config file. For more information about processing custom configuration data, see the M:Microsoft.ReportingServices.Interfaces.IExtension.SetConfiguration(System.String) method.
The class that implements T:Microsoft.ReportingServices.Interfaces.IExtension is not unloaded from memory when the rest of your data processing extension classes are unloaded. Because of this, you can use your Extension class to store cross-connection state information or to store data that can be cached in memory. Your Extension class remains in memory as long as the report server is running.
You can extend your Connection class to include support for credentials in Reporting Services by implementing T:Microsoft.ReportingServices.DataProcessing.IDbConnectionExtension. When you implement the P:Microsoft.ReportingServices.DataProcessing.IDbConnectionExtension.IntegratedSecurity, P:Microsoft.ReportingServices.DataProcessing.IDbConnectionExtension.UserName, and P:Microsoft.ReportingServices.DataProcessing.IDbConnectionExtension.Password properties of the T:Microsoft.ReportingServices.DataProcessing.IDbConnectionExtension interface, you enable the Integrated Security check box and Username and Password text boxes of the Data Source dialog in Report Designer. This enables Report Designer to store and retrieve credentials for data sources that support authentication. The credentials are stored securely and used when rendering reports in preview mode.
Implementing T:Microsoft.ReportingServices.DataProcessing.IDbConnectionExtension implicitly requires you to implement the members of the T:Microsoft.ReportingServices.DataProcessing.IDbConnection and T:Microsoft.ReportingServices.Interfaces.IExtension interfaces.
For a sample Connection class implementation, see SQL Server Reporting Services Product Samples.