Link to home
Start Free TrialLog in
Avatar of rwheeler23
rwheeler23Flag for United States of America

asked on

Calling an SSRS from VS C# 2008

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

Avatar of Bob Learned
Bob Learned
Flag of United States of America image

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
Avatar of rwheeler23

ASKER

I will check out this tech note. My test applicaition still keeps on crashing.
06-17-10-1-05-25-PM.pdf
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?
The root path is the URL for the server, and the report path is relative to the root path.
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.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial