Crystal Reports - Always saving data

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
vaughnwhiteheadAsked:
Who is Participating?
 
mlmccCommented:
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
 
mlmccCommented:
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
 
vaughnwhiteheadAuthor Commented:
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
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
mlmccCommented:
Try using only 1 refresh or remove both refreshes.

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

mlmcc
0
 
vaughnwhiteheadAuthor Commented:
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
 
mlmccCommented:
Does the process clear the database/table before adding records?

mlmcc
0
 
vaughnwhiteheadAuthor Commented:
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
 
mlmccCommented:
What SQL is the report running when it shows 400?

mlmcc
0
 
mlmccCommented:
If you refresh the report does it show the correct amount?

mlmcc
0
 
vaughnwhiteheadAuthor Commented:
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
 
mlmccCommented:
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
 
vaughnwhiteheadAuthor Commented:
I am using the CR Count{} funtion.
0
 
mlmccCommented:
Can you upload the report?

mlmcc
0
 
vaughnwhiteheadAuthor Commented:
The report and db did not upload.  Will do it again tonight.
0
 
vaughnwhiteheadAuthor Commented:
CR and Access db
ETPrint.mdb
CrExamStats.rpt
0
 
mlmccCommented:
I don't see anything in the report that would cause the issue.

what code do you use to update the data?

mlmcc
0
 
vaughnwhiteheadAuthor Commented:
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
 
vaughnwhiteheadAuthor Commented:
I delete with code.  I will modify to see the records.  I delete the records and then open the report.
0
 
vaughnwhiteheadAuthor Commented:
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
 
vaughnwhiteheadAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.