We open the same Visual Studio project that we created in our article here.

Infragistics provides a specific template named “Infragistics Report Database Connection Provider” that implements the “IReportDbConnectionProvider” interface. We add a class to our project as shown below and name it “ReportDbConnectionProvider.cs”.

By default the template gives you the following code.

Now we need to identify the name of the Data Source used in our report. This can be found under the Data Sources section in the “Report Data Explorer” window as in the following.

Implement the following code in your “ReportDbConnectionProvider.cs” file.
- public DbConnection GetConnection(string name, IDictionary < string, ParameterValue > reportParameters)
- {
- switch (name)
- {
- case "sqlDatSource1":
- return new SqlConnection(@
- "Data Source=NITESH\SQLEXPRESS;Initial Catalog=SampleDB;Integrated Security=True");
- default:
- return null;
- }
- }
As you see above, I have added code in GetConnection() and returned an SqlConnection object with my custom connection string for the data source named “sqlDataSource1” that is the Data Source used by our project.
Now, when you execute the project, your report will use the new connection string.
I hope you like this article. Keep learning and sharing.

NitinPosted May 8, 2015, 12:18 PM
nice
Sibeesh VenuPosted May 8, 2015, 7:06 AM
Good one .
Santhakumar MunuswamyPosted May 7, 2015, 3:36 PM
Thanks for nice article