Refresh Crystal Report in VB.Net Using Saved Parameters

by Bill Dowling 17. July 2013 10:18
The following code can be used to refresh a Crystal Report file within a VB.Net program using the saved parameter values and output the results to a PDF file. It assumes you have a ReportDocument called rptDoc on your form. Me.UseWaitCursor = TrueMe.rptDoc.Load("T:\SummaryInvoice.rpt")Me.rptDoc.SetDatabaseLogon("user", "pw")'***************************************' Get the Current Saved Parameter Values'***************************************Dim nParameters As Integer = Me.rptDoc.ParameterFields.CountDim pfs As New List(Of CrystalDecisions.Shared.ParameterValues)For nIndex As Integer = 0 To nParameters - 1    pfs.Add(Me.rptDoc.ParameterFields(nIndex).CurrentValues)Next'****************************' Reload the Parameter Values'****************************Me.rptDoc.Refresh()For nIndex As Integer = 0 To nParameters - 1    Me.rptDoc.SetParameterValue(nIndex, pfs(nIndex))NextMe.rptDoc.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, "T:\SummaryInvoice.pdf")Me.UseWaitCursor = FalseMessageBox.Show("All done")


.Net Coding Examples | Crystal Report

About the author

Bill Dowling has been a VB and .Net programmer for as long as he can remember.

Month List