Retrieve reports from reporting server in Asp.Net (vs2005)

Dear experts,

I have created and uploaded a report (rdl) to our reporting server http://www.xxxx.com/Reports2005.

Now I want to retreive the report from the asp.net page. Can someone provide me the code on how to call it. I am very new to the SQLServer reporting  services.

Thanks for help.
LuckyColdAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gigglickCommented:
Include this namespace in you code behind:using System.Data.SqlClient;
Drop a ReportViewer control onto your asp page

Here is a snippit of code I use to refresh a report that has five parameters:
 ///refresh the report
            this.ReportViewer1.ServerReport.ReportServerUrl =
            new System.Uri("http://MyServer/reportserver");

            //while (this.ReportViewer1.ServerReport.IsDrillthroughReport)
            //{
            //    this.ReportViewer1.PerformBack();
            //}


                this.ReportViewer1.ServerReport.ReportPath = "/ReportFolder/ReportName";
           


            //this.ReportViewer1.ServerReport.ReportPath = strReport;

            Microsoft.Reporting.WebForms.ReportParameter[] RptParameters =
                new Microsoft.Reporting.WebForms.ReportParameter[5];

            //string strTime = System.DateTime.Now.ToShortTimeString();
            RptParameters[0] =
                new Microsoft.Reporting.WebForms.ReportParameter("account_ID", TheAccount.accountID.ToString());
            //RptParameters[1] =
            //   new Microsoft.Reporting.WebForms.ReportParameter("date", DropDownList2.Text.ToString());
            RptParameters[1] =
               new Microsoft.Reporting.WebForms.ReportParameter("statement_Date", DropDownList4.Text.ToString());
            RptParameters[2] =
                new Microsoft.Reporting.WebForms.ReportParameter("startdate", "6/30/2006".ToString());//this date doesn't matter its filler
            RptParameters[3] =
                new Microsoft.Reporting.WebForms.ReportParameter("enddate", DropDownList4.Text.ToString());
            RptParameters[4] =
                new Microsoft.Reporting.WebForms.ReportParameter("period", DropDownList2.Text.Substring(0, 1).ToString());

            this.ReportViewer1.ServerReport.SetParameters(RptParameters);

            this.ReportViewer1.ServerReport.Refresh();
            this.ReportViewer1.Visible = true;
0
LuckyColdAuthor Commented:
Hi Gigglick,
Thanks for the quick response.
I have implemented what you said and  I got the error message -  the attempt to connect to the report server failed. Check your connection information and that the report server is a compatible version.

The request failed with http status 404:not found.

Please advise.

Thanks a million,
Here is the code:


Imports System.Data.SqlClient


Partial Class _Default
    Inherits System.Web.UI.Page

     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.ReportViewer1.ServerReport.ReportServerUrl = New System.Uri("http://myreportservername.com/reports2005")
        Me.ReportViewer1.ServerReport.ReportPath = "Reports/Report1"
        Me.ReportViewer1.ServerReport.Refresh()
        Me.ReportViewer1.Visible = True
    End Sub
End Class


0
ralmadaCommented:
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

gigglickCommented:
Hi -

Sorry didn't realize you hadn't needed to connect to your server at all yet.   You'll need to set up a database connection: This shoudl come before the report server refresh code.

SqlConnection cn = new SqlConnection("Data Source=MyServer;Initial Catalog=MyDatabase;Integrated Security=True");
0
LuckyColdAuthor Commented:
Hi Gigglick,
I am ready to go home and I'll try tonight.

Relmada, I already checked the site before I posted the questions. Thanks anyway.
0
LuckyColdAuthor Commented:
Hi Gigglick,
Sorry for the late response. Howerver, I still got the same error "The request failed with HTTP status 404: Not Found. "  from the IE browser page.    On the ie browser address, it shows "http://localhost:1035/ReportingServices/Default.aspx", but my report is resided on the reporting server (myreportname)  not on my workstation.  Do you have any clues? Please help. Thanks a million.

 Here is the code on mydefault aspx page:


Imports Microsoft.VisualBasic
Imports System.Web.Configuration
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient
Partial Class _Default
    Inherits System.Web.UI.Page
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim connectionstring As String = "Data Source=MYDATASOURCE;Initial Catalog=TestDatabase;Integrated Security=True"
        Dim con As New SqlConnection(connectionstring)
        con.Open()
        Me.ReportViewer1.ServerReport.ReportServerUrl = New System.Uri("http://myreportname.com/reports2005")
        Me.ReportViewer1.ServerReport.ReportPath = "/Reports/Report1"
        Me.ReportViewer1.ServerReport.Refresh()
        Me.ReportViewer1.Visible = True
        con.Close()
    End Sub
End Class
0
gigglickCommented:
First try taking the .com extension off your report server name in this line of code:

Me.ReportViewer1.ServerReport.ReportServerUrl = New System.Uri("http://myreportname.com/reports2005")

0
LuckyColdAuthor Commented:
Hi Gigglick,
Yes, I tried it and still go the same error.
 

 
0
gigglickCommented:
http://localhost:1035/ReportingServices/Default.aspx"  I am assuming you are building the asp page on your local machine in visual studio which will open up on a local port which is the first part of that path.  The /ReportingServices/ should be the name of your project and Default.aspx is the default start up page.    If you are getting that error while you are trying to open the page this is likely an issue with your webconfig file.  You wont see the address for the report server appear in your address bar as all of that processing is being handled during the postback.   The code you have above should work so it sound like you've got other issues going on with your website.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LuckyColdAuthor Commented:
Hi Gigglick,

It works now. I am going to close the solution

Thanks a lot for your help.
0
gigglickCommented:
No probs. glad you got it working
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.