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 = True
Me.rptDoc.SetDatabaseLogon("user", "pw")
' Get the Current Saved Parameter Values
Dim nParameters As Integer = Me.rptDoc.ParameterFields.Count
Dim pfs As New List(Of CrystalDecisions.Shared.ParameterValues)
For nIndex As Integer = 0 To nParameters - 1
' Reload the Parameter Values
For nIndex As Integer = 0 To nParameters - 1
    Me.rptDoc.SetParameterValue(nIndex, pfs(nIndex))
Me.rptDoc.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, "T:\SummaryInvoice.pdf")
Me.UseWaitCursor = False
MessageBox.Show("All done")


.Net Coding Examples | Crystal Report

Add comment

About the author

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

Month List