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,623 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
Comment Utility
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
Comment Utility
0
 
LVL 27

Accepted Solution

by:
planocz earned 250 total points
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Library to convert HTML to PDF. 8 44
.Net application crashing 6 19
GRANT, REVOKE, DENY 4 16
Spacing between controls 4 15
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

17 Experts available now in Live!

Get 1:1 Help Now