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,675 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

803 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