How to pass ServerName and DatabaseName parameters to SSRS Report Control to generate reports

Viewed 17

Trying to pass in the value for the server name and database name into the the SSRS report control to generate customize reports.

The following are the parameters that appear in when accessing the SSRS server directly. enter image description here

The following code is what I have tried so far:

ReportParameter serverNameParameter  = new ReportParameter("ServerName");
serverNameParameter.Values.Add(serverName);
this.ReportViewer1.ServerReport.SetParameters(serverNameParameter);

ReportParameter databaseNameParameter = new ReportParameter("Database Name");
databaseNameParameter.Values.Add(databaseName);
this.ReportViewer1.ServerReport.SetParameters(databaseNameParameter);

Getting an error exception that indicates that "ServerName" parameter does not exist. Is there a better approach to passing the values of these parameters to the SSRS report viewer controls?

1 Answers

Had to go into the SSRS server and had to add manually add those parameters to the report using Microsoft Report Builder. After adding those parameters with the Report Builder tool, the parameters are able to be passed in.

Related