Solved

How to use dataset of .rdl file in web application (asp.net) after converting it to .rdlc visual studio 2008 C# and SSRS 2008 R2

Posted on 2011-09-12
5
1,652 Views
Last Modified: 2013-11-26



Hi,

I have a situation where I need to use a report which was created initially in SSRS 2008 R2 and has .rdl extension. Now, I want to use this report on asp.net (C#) page.
I have added this report in web application package and changed it's extension to .rdlc and droped reportviewer control on design area and assigned imported .rdlc file to it.
Can you please tell me how to use the existing datasets of the report file. As I could not find any option to use the data source already present in the report.
In the meanwhile if go to report's code in xml view I can see all sql statements which are being used in the dataset!!!!!!!!!!


Your comments and suggestions are highly appreciated.

Thanks.
0
Comment
Question by:ezkhan
  • 2
5 Comments
 
LVL 9

Assisted Solution

by:mimran18
mimran18 earned 250 total points
ID: 36527519
Hi,
     Try this.But you donot need to do step 1 and Step 2 because you have already included file in project.
You also need to change names in this code
           <LocalReport ReportPath="Report.rdlc">
                <DataSources>
                    <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1" />
                </DataSources>
            </LocalReport>
        </rsweb:ReportViewer>
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetData"
            TypeName="testreportDataSetTableAdapters.Get_Address_spTableAdapter"></asp:ObjectDataSource>

Reference : http://www.c-sharpcorner.com/UploadFile/jayendra/7738/
0
 
LVL 9

Expert Comment

by:mimran18
ID: 36527522
0
 
LVL 27

Accepted Solution

by:
planocz earned 250 total points
ID: 36557712
Rdl and Rdlc are used the same way. There is nothing to chnce in the dataset.
I do not know if this will help you using VB.net  but this is the kind of code we use on the web site side to view a rdl report in a PDF format. Can be used in 2005 or 2008
Imports System
Imports System.IO
Imports System.Data
Imports System.Web.Services.Protocols
Imports Microsoft.SqlServer.ReportingServices2005.Execution

Partial Class RdlViewer
    Inherits System.Web.UI.Page
    Private ReportName As String = "MyReportName"
    Private DirPath As String = "MyDirectory"
    'Private objParameters(25) As Microsoft.Reporting.WebForms.ReportParameter
    Private pdfParameters(25) As ParameterValue

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.Buffer = True
        Response.Expires = -1442
        Response.AddHeader("cache-control", "private")
        Response.AddHeader("pragma", "no-cache")

        If Not Page.IsPostBack Then
            Dim ServerUri As New Uri(System.Configuration.ConfigurationManager.AppSettings("ReportServerURL"))
            ReportViewer1.ServerReport.ReportServerUrl = ServerUri
            ReportViewer1.ServerReport.ReportPath = "/ServerReports/" & DirPath & "/" & ReportName

            'Go get the report parameters
            PDFParams()

            'Go run the report viewer in PDF Screen
            asPDF()


        End If
    End Sub

    Sub PDFParams()

 'Test Parameters that you setup or add to your code
        pdfParameters(0) = New ParameterValue    'SQL2008.ParameterValue
        pdfParameters(0).Name = "CustomerID"
        pdfParameters(0).Value = "10000"    'Session("ProspectID")
        pdfParameters(1) = New ParameterValue    'SQL2008.ParameterValue
        pdfParameters(1).Name = "ProductID"
        pdfParameters(1).Value = "2000"   
        pdfParameters(2) = New ParameterValue    'SQL2008.ParameterValue
        pdfParameters(2).Name = "CustomerName"
        pdfParameters(2).Value = "John Doe"            pdfParameters(3) = New ParameterValue    'SQL2008.ParameterValue
        pdfParameters(3).Name = "CustAddress"
        pdfParameters(3).Value = "1200 West South Street"    
        pdfParameters(4) = New ParameterValue    'SQL2008.ParameterValue
        pdfParameters(4).Name = "CustCityStateZip"
        pdfParameters(4).Value = "Dallas TX 75214"    
    End Sub


    Sub asPDF()
        Dim rs As New ReportExecutionService()
        rs.Credentials = System.Net.CredentialCache.DefaultCredentials
        rs.Url = System.Configuration.ConfigurationManager.AppSettings("sql2008.ReportExecution2005")

        ' Render arguments
        Dim result As Byte() = Nothing
        Dim reportPath As String = "/" & DirPath & "/" & ReportName
        Dim format As String = "PDF"
        Dim historyID As String = Nothing
        Dim devInfo As String = "<DeviceInfo><StreamRoot>/RSWebServiceXS/</StreamRoot></DeviceInfo>"

        Dim encoding As String = Nothing
        Dim mimeType As String = Nothing
        Dim warnings As Warning() = Nothing  'SQL2008.Warning() = Nothing
        Dim streamIDs As String() = Nothing

        Dim execInfo As New ExecutionInfo
        Dim execHeader As New ExecutionHeader
        Dim extension As String = ""

        rs.ExecutionHeaderValue = execHeader

        execInfo = rs.LoadReport(reportPath, historyID)

        rs.SetExecutionParameters(pdfParameters, "en-us")
        rs.Timeout = 600 * 1000   'timeout in milliseconds (defaults to 100,000 = 100 seconds)

        result = rs.Render(format, devInfo, extension, mimeType, encoding, warnings, streamIDs)

        Response.ClearContent()
        Response.ContentType = "application/pdf"
        Response.BinaryWrite(result)
        Response.Flush()
    End Sub

' #### this is placed in your web.config file
<appSettings>
    <add key="ReportServerURL" value="http://MyServerName/ReportServer"/>
    <add key="ReportServerName" value="MyServerName"/>
      <add key="sql2008.ReportExecution2005" value="http://MyServerName/ReportServer/ReportExecution2005.asmx"/>  
  </appSettings>
 

Toggle HighlightingOpen in New WindowSelect All

Open in new window

0
 
LVL 100

Expert Comment

by:mlmcc
ID: 36998441
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A recent question popped up and the discussion heated up regarding updating a COMMENTS (TXT) field in a table using SSRS. http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/MS-SQL_Reporting/Q_27475269.html?cid=1572#a37227028 (htt…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now