locked
standalone rdlc with external dataset and pdf rendering RRS feed

  • Question

  • Hi,

    I need to create a report in SSRS 2015 but I need to bind that report to an external dataset .

     I need it to work with parameters  and stored procedure.

    Another issue is that the report is standalone -rdlc.

    Can I call the report from a webservice .asmx not wcf and render it automatically in pdf format?

    Can anyone please provide me with examples?

    Thanks

    Wednesday, August 26, 2015 4:23 PM

Answers

  • Hi collie12,

    According to your description, you want to create a RDLC report with data retrieved by stored produce and parameters, then you want to export the report to PDF automatically, right?

    In your scenario, to create an RDLC, we can use report viewer control in the application to integrate with reporting services.  If you want to retrieve the dataset using the stored procedure, you should pass the parameters to it from the user interface. So you can create a cascaded user control in ASP.NET pages to pass the parameters to your store procedure to retrieve the dataset for your local report. For more information, please refer to this thread: Can We filter the Custom data source using Report parameter in RDLC files?.

    Besides, to save the RDLC report to PDF without render the report then click the export option in report viewer control, please take a look at sample code in those threads below:
    Creating a PDF from a RDLC Report in the Background
    Save RDLC reports as PDF programmatically
    RDLC - Export directly to Excel or PDF from codebehind
     
    If you have any question, please feel free to ask.

    Best regards,
    Qiuyun Yu


    Qiuyun Yu
    TechNet Community Support


    Thursday, August 27, 2015 6:10 AM
  • Hi collie12,

    When we add a new reportviewer control, then click the "Design a new report", then the data source wizard will prompt like below:

    In your scenario, since you mention reportviewer control asks you to specify the data source, does it occur when you click "Design a new report" button? If that is a case, it's a necessary step, you shouldn't be worry about that.

    Best regards,
    Qiuyun Yu


    Qiuyun Yu
    TechNet Community Support


    Wednesday, September 2, 2015 9:55 AM

All replies

  • Hi Collie,

    The below links will help you for sure :)

    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/5d5a035c-36cd-4937-a76e-7f12bcd06201/render-to-pdf-directly?forum=sqlreportingservices
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/a09d26ad-776a-447c-ab1a-ab59e1f8f667/reporting-services-auto-export-to-pdf?forum=sqlreportingservices


    Please Dont forget to mark as answer and Helpful Post. It helps others to find relevant posts to the same question. Milan Das

    Wednesday, August 26, 2015 4:59 PM
  • Thanks Milan.

    This is what I came up with and it seems to work.

    I added a reportviewer to asp.net with visible=false.

    In rdlc I added a Dataset named DataSet1 same name as my dataset in my code.

    In rdlc I binded the dataset created there to a table in sql and dragged a table to the report body and added the fields from the db table.

    When running the report it seems to get the values from my code and not from the internal dataset. This is perfect.

    Did I do it correctly?

      Private Sub all()        Dim ds As DataSet = New DataSet()        Dim dt As DataTable = New DataTable()        dt.Columns.Add("playerid")        dt.Columns.Add("playername")        dt.Rows.Add("1", "dog")        dt.Rows.Add("2", "cat")        dt.Rows.Add("3", "bird")        dt.Rows.Add("4", "lion")        ds.Tables.Add(dt)        ReportViewer1.Reset()        ReportViewer1.LocalReport.ReportPath = "reports\report1.rdlc"        Dim rs As ReportDataSource = New ReportDataSource()        rs.Name = "DataSet1"        rs.Value = ds.Tables(0)        ReportViewer1.LocalReport.DataSources.Add(rs)        Dim warnings As Warning() = Nothing        Dim streamids As String() = Nothing        Dim mimeType As String = Nothing        Dim encoding As String = Nothing        Dim extension As String = Nothing        ' Setup the report viewer object and get the array of bytes        ReportViewer1.ProcessingMode = ProcessingMode.Local        'viewer.LocalReport.DataSources.Add(rds)        Dim bytes As Byte() = ReportViewer1.LocalReport.Render("PDF", Nothing, mimeType, encoding, extension, streamids, _        warnings)        Dim Filename As String = "reportpdf"                 ''save file immediately without opening 'hide reportviewer if you don't want user to see it        Dim fs As FileStream = System.IO.File.Create("c:\avital\" & Filename & ".pdf")        fs.Write(bytes, 0, bytes.Length)        fs.Close()    End Sub

    Wednesday, August 26, 2015 8:55 PM
  • Hi collie12,

    According to your description, you want to create a RDLC report with data retrieved by stored produce and parameters, then you want to export the report to PDF automatically, right?

    In your scenario, to create an RDLC, we can use report viewer control in the application to integrate with reporting services.  If you want to retrieve the dataset using the stored procedure, you should pass the parameters to it from the user interface. So you can create a cascaded user control in ASP.NET pages to pass the parameters to your store procedure to retrieve the dataset for your local report. For more information, please refer to this thread: Can We filter the Custom data source using Report parameter in RDLC files?.

    Besides, to save the RDLC report to PDF without render the report then click the export option in report viewer control, please take a look at sample code in those threads below:
    Creating a PDF from a RDLC Report in the Background
    Save RDLC reports as PDF programmatically
    RDLC - Export directly to Excel or PDF from codebehind
     
    If you have any question, please feel free to ask.

    Best regards,
    Qiuyun Yu


    Qiuyun Yu
    TechNet Community Support


    Thursday, August 27, 2015 6:10 AM
  • Thanks, when I add a reportviewer it asks me to specify the datasource for each dataset. Is this correct?
    Sunday, August 30, 2015 8:37 PM
  • Hi collie12,

    When we add a new reportviewer control, then click the "Design a new report", then the data source wizard will prompt like below:

    In your scenario, since you mention reportviewer control asks you to specify the data source, does it occur when you click "Design a new report" button? If that is a case, it's a necessary step, you shouldn't be worry about that.

    Best regards,
    Qiuyun Yu


    Qiuyun Yu
    TechNet Community Support


    Wednesday, September 2, 2015 9:55 AM