Solved

Refresh Crystal Report after Print taken

Posted on 2011-03-03
5
629 Views
Last Modified: 2012-05-11
hi,

I have one report developed in .net application. Now say a user views the report and wish to print that report. hence for printing we have used our own Print Button and not the Crystal Report viewer default print button as we need to store the print date in database (which is today's date).

Said that, now when the print button is clicked, i wish the report to be refresh. I have tried Crystal Report.Refresh and ReportRefresh. The refresh does nothing while report refresh does refresh BUT it asks for the parameter (prompt for all the parameters in the report)

hence, what should i do in this case?

I have attached my code for View button and print button.

Kindly have a look as to get an idea of how view and print works.

Thanks much!
View-Code.txt
Print-Code.txt
0
Comment
Question by:meispisces
  • 2
5 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 35031394
WHy do you feel the need to refresh the report?

Printing it will use the existing parameters and run the report with current data assuming you don't have saved data.

Refresh causes the report to discard the parameters and want new ones.

mlmcc
0
 
LVL 7

Author Comment

by:meispisces
ID: 35033796
@mlmcc: Because once the report is printed out, the report should become blank (showing no data in it). By blank, doesn't mean that the database should be cleared off.
0
 
LVL 18

Accepted Solution

by:
UnifiedIS earned 500 total points
ID: 35038120
A method to handle this is to cache the parameters.  Then you reload and reapply the saved parameters.

Here's a piece of some code that does this:
crv is my crystalreportviewer control
I use a class called ParameterValuePairs that houses the parameter name and value.

rptPersistent = New CrystalDecisions.CrystalReports.Engine.ReportDocument
            rptPersistent.Load(_ReportPath)
            If Not Me.crv.ReportSource Is Nothing Then
                Dim rptTemp As CrystalDecisions.CrystalReports.Engine.ReportDocument = crv.ReportSource
                Dim PVP As ParameterValuePairs
                Dim PVS As CrystalDecisions.Shared.ParameterValues
                Dim PV As CrystalDecisions.Shared.ParameterValue
                Dim PVS2 As CrystalDecisions.Shared.ParameterValues
                arParameterValues = New ArrayList
                For Each pf As CrystalDecisions.Shared.ParameterField In rptTemp.ParameterFields
                    PVS = pf.CurrentValues
                    For Each pf2 As CrystalDecisions.Shared.ParameterField In rptPersistent.ParameterFields
                        If pf2.Name = pf.Name Then
                            PVS2 = pf2.CurrentValues
                            For Each PV In PVS
                                PVP = New ParameterValuePairs(pf.Name, PV)
                                PVS2.Add(PV)
                            Next
                        End If
                    Next
                Next
                rptTemp.Close()
                rptTemp.Dispose()
            End If
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 35275389
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question