Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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,693 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

839 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