Solved

Refresh Crystal Report after Print taken

Posted on 2011-03-03
5
655 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 101

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 101

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

705 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