We help IT Professionals succeed at work.

Calling an SSRS from VS C# 2008

rwheeler23
rwheeler23 asked
on
I was testing how to call an SSRS from with C#.
My server name is datamiing ( this is where SSRS is located)
The report name is Top20Vendors
The actual SQL instance were the SSRS database is located is dataserver

This program always crashes on the
ReportViewer1.ServerReport.SetParameters(Parameters);
line saying the path is invalid. I have tried every combination.

What am I missing here?
public Form1()
        {
            InitializeComponent();

            ReportViewer ReportViewer1 = new ReportViewer();


            ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://datamining/reportserver");
            List<ReportParameter> Parameters = new List<ReportParameter>(); 
            string ParamValue = TextBox1.Text;  
            ///''This is just an example of getting the value of a textbox  
            Parameters.Add(new ReportParameter("BegDate", "01/01/2010"));
            Parameters.Add(new ReportParameter("EndDate", "12/31/2010"));
            ReportViewer1.ServerReport.ReportPath = "//datamining/Reports/Top20Vendors";  
            ReportViewer1.ServerReport.SetParameters(Parameters);  
            ReportViewer1.ProcessingMode = ProcessingMode.Remote;  
            ReportViewer1.ServerReport.Refresh(); 
        }

        private void Form1_Load(object sender, EventArgs e)
        {

            this.reportViewer1.RefreshReport();
        }

Open in new window

Comment
Watch Question

Most Valuable Expert 2012
Top Expert 2008

Commented:
I believe that the path should be like this:

ReportViewer1.ServerReport.ReportPath = "Reports/Top20Vendors";

You already specified the server name in the ReportServerUrl.  The ReportPath is a relative path based on the server URL.

Reference:

Using SQL Server 2005 Reporting Services with SQL Server 2005 Express Edition
http://msdn.microsoft.com/en-us/library/cc966542.aspx
IC217502.jpg
rwheeler23President

Author

Commented:
I will check out this tech note. My test applicaition still keeps on crashing.
06-17-10-1-05-25-PM.pdf
rwheeler23President

Author

Commented:
In this case, SSRS is on one server and the reporting database is on another server. Should I be specifying the name of the server that contains the database and not just the SSRS engine?
Most Valuable Expert 2012
Top Expert 2008

Commented:
The root path is the URL for the server, and the report path is relative to the root path.
rwheeler23President

Author

Commented:
This is why I cannot understand why I keep getting "Report not Found". When I go into SSRS and properties of the report, I am copying that exact path into my program. It looks exactly as it appears above. When I get back later today I will copy all of my code into this thread.
Most Valuable Expert 2012
Top Expert 2008
Commented:
If you have a path like this:

    ReportViewer1.ServerReport.ReportPath = "//datamining/Reports/Top20Vendors";  

you need to remove the server name from the path.

ReportViewer1.ServerReport.ReportPath = "/Reports/Top20Vendors";