Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Crystal Reports - Always saving data

Posted on 2012-09-16
20
Medium Priority
?
1,580 Views
Last Modified: 2012-09-21
Greetings,

My Crystal Report  saves data and then on the next run, the data doubles.  Below is my code:

Try
            With crConnectionInfo
                .DatabaseName = dbase
                .UserID = ""
                .Password = ""
            End With
            CrTables = cryRpt.Database.Tables
            For Each CrTable In CrTables
                crtableLogoninfo = CrTable.LogOnInfo
                crtableLogoninfo.ConnectionInfo = crConnectionInfo
                CrTable.ApplyLogOnInfo(crtableLogoninfo)
            Next
            cryRpt.SetDatabaseLogon("", "")
   
           crViewerStats.ReportSource = cryRpt
           cryRpt.Refresh()
           crViewerStats.Refresh()
           crViewerStats.PrintReport()
           
        Catch ex As Exception
                        MessageBox.Show("Problem printing reports: " & ex.Message, "",        MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

I refresh the report and viewer, but the report adds the new data to the previous data.  It's obviously storing the data in the report.

Thanks

VW
0
Comment
Question by:vaughnwhitehead
  • 11
  • 9
20 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 38403732
Do you have the SAVE DATA WITH REPORT option set?
If so turn it off

Try using this line before the refresh
  cryRpt.DiscardSavedData

mlmcc
0
 

Author Comment

by:vaughnwhitehead
ID: 38404175
Yes, I have the Save Data with Report unchecked .   This is what makes no sense.  With the Save data report unchecked, why would the data be reused.  I checked the database to be sure that the data was not being doubled, but but it is being erased and then rewritten.

The   cryRpt.DiscardSavedData  command gives me the cannot resolve symbol error. ??

VW
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 38404282
Try using only 1 refresh or remove both refreshes.

If there is no saved data then there is no need to refresh.

mlmcc
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:vaughnwhitehead
ID: 38405916
The problem has taken another turn. The process dumps exam scores to the database and then the CR generates standard  stats (mean, median, mode, sd, reliability, etc.    mimcc (above response) got me to thinking about the saved data.  My first stat is a count of the records.  

Count ({ExamGrades.Score})  

This field keeps incrementing, but the other stats are being computed correctly.  So, why would the count not correctly indicate the correct number or records?

Actually, I guess this may be a second question.  

VW
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 38407873
Does the process clear the database/table before adding records?

mlmcc
0
 

Author Comment

by:vaughnwhitehead
ID: 38407934
Yes, I delete all the records before I write to the table.   When the report is stating that there are 400 records, i can pull up the database and only have 148
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 38408077
What SQL is the report running when it shows 400?

mlmcc
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 38408080
If you refresh the report does it show the correct amount?

mlmcc
0
 

Author Comment

by:vaughnwhitehead
ID: 38409634
I am using a Select All query.  I had the refresh reports in, but will try putting them in again.  The really strange part is if I run the report; open the database and manually adjust some of the scores, and then refresh the report, the stats are correctly changed, but the number of records is still incorrect.

One other point.  I originally create the report in the IDE, but have occassionally used Crystal Reports 2008 to view the report and sometimes make minor changes to the formatting.  Could this be a problem?

Thanks for your input and time.

VW
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 38410659
How are you getting the number of records?

The editting in CR2008 is possibly the issue but CR4VS2010 was supposed to be CR v13 which I would think included all of CR2008 (v12)

mlmcc
0
 

Author Comment

by:vaughnwhitehead
ID: 38410696
I am using the CR Count{} funtion.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 38411431
Can you upload the report?

mlmcc
0
 

Author Comment

by:vaughnwhitehead
ID: 38413844
The report and db did not upload.  Will do it again tonight.
0
 

Author Comment

by:vaughnwhitehead
ID: 38414842
CR and Access db
ETPrint.mdb
CrExamStats.rpt
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 38416047
I don't see anything in the report that would cause the issue.

what code do you use to update the data?

mlmcc
0
 

Author Comment

by:vaughnwhitehead
ID: 38416152
I use oledb. I use a delete all before the insert into.  After the insert there are only 148  records.  How the count function returns there increasing number, is strange. Could the fact that the functions are in the header cause a problem?
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 2000 total points
ID: 38416187
That shouldn't matter.

How are you deleting?

Is it through code or do you open the database and delete the records directly?

Can you modify the report to display the records?

Do you fully close the report before you delete the records?

mlmcc
0
 

Author Comment

by:vaughnwhitehead
ID: 38423008
I delete with code.  I will modify to see the records.  I delete the records and then open the report.
0
 

Author Comment

by:vaughnwhitehead
ID: 38423105
I display the records in the report and there are approx 1200. ) It keeps incrementing each time.)  While the report is being displayed, I open the database and there are 89 records.

???
0
 

Author Comment

by:vaughnwhitehead
ID: 38423580
Now for the strange part.  If I print the scores in the detail section of the report and place the data in the Report Footer, everything prints correctly.   I guess I will stay with this.  I appreciate the input and time from mimcc and am going to award the points  

Thanks again
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

581 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