standalone rdlc with external dataset and pdf rendering

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

August 26th, 2015 12:36pm

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

Free Windows Admin Tool Kit Click here and download it now
August 26th, 2015 1:11pm

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

August 26th, 2015 5:07pm

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

Free Windows Admin Tool Kit Click here and download it now
August 27th, 2015 2:22am

Thanks, when I add a reportviewer it asks me to specify the datasource for each dataset. Is this correct?
August 30th, 2015 4:39pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics