'create the report and save to a temp location
Dim rv As New Microsoft.Reporting.WinForms.ReportViewer
rv.Reset()
rv.LocalReport.DataSources.Clear()
rv.ProcessingMode = ProcessingMode.Local
'query the database and get a datasource
Dim oDT As DataTable = SPs.fp_FPTakeoffQuote_SEL_forGrid(mintMasterNumber, App.ConnectionString).getTable
'assign the datasource to the report. The dataset name in SSRS is 'DataSet1' by default, but it might have been changed.
'the name is case sensitive
rv.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", oDT))
'this code is from asp.net, the report is in the root folder
rv.LocalReport.ReportPath = Server.MapPath("TakeoffQuote.rdl")
rv.RefreshReport()
'write the report to disk.
Dim oByte() As Byte
oByte = rv.LocalReport.Render("pdf")
Dim strFileName As String = Path.Combine(Server.MapPath("FilesTEMP"), mintMasterNumber & ".pdf")
If File.Exists(strFileName) Then
File.Delete(strFileName)
End If
'use filestream to save byte array to a file
Dim fs As New IO.FileStream(strFileName, IO.FileMode.Create)
fs.Write(oByte, 0, oByte.Length)
fs.Close()
fs = Nothing