C# program with repeating records printed in Crystal report

G

Guest

I have a C# program that user would select several search criteria and then
outputs to the Crystal Report. A message is output to user if no matching
record is found. In my code I also clear, removed and dispose of the table
in the dataset that was used which should have nothing in it any way. I then
clean up the search string that I built at run time.

Now in the same screen, user change one of the search criteria and now there
are matching records. However, each records are repeated n time for each
prior search that has no matching records.

I have examined the row counts in the dataset while in the debug mode(int y
= dsLocal.Tables["trips"].Rows.Count;) and it shows 5 trips but once it goes
to crystal it would double or triple of that.

This repeating problem only occurs after the no match record message is
printed. If user was able to find matching record each time then no repeated
records will show in the report.

I'm not sure and don't know if this is a C# or Crystal problem. Would be
great I I can first just determin that. Very strange bug and appreciate any
help,
Alpha
 
B

Bruce Wood

My first guess is that there is some other table in the data set you
are passing to Crystal, and that table has foreign keys back into the
table that you're working with... something like that.

The only way I know of to have Crystal produce multiple copies of data
is to make mistakes in grouping / table joins. In other words, have
multiple tables and report at the wrong level in the hierarchy,
together with messed up table linkages.

Does the DataSet you set as your Crystal data source have any tables in
it other than the one you want to report on?

As well, you might want to call AcceptChanges() on the data set before
passing it to Crystal, just in case that is affecting things (but it
doesn't sound like that's the problem).
 
G

Guest

The problem is in the dataset. I've tried working on different things all
day again today and found there is one way to get rid of this repeating rows
printing. It repeats as many times as the user gets a message saying 'no
matching records found'. I put the following in after the message:

dsLocal.Tables.Clear();
dsLocal.Dispose();

The problem goes away. There are 2 tables that I put in this dataset,
Trips, Balances and Global. Global contains only stuff for header in
Crystal. Trips and balances are the ones with data.

I finally found the bug just now!!!! It's not my query it's not my crystal
report...... It's after the no matching record I clear and removed the Trips
and Balances tables but forgot to do so for the 'Global' table!!!!!! So so
so very frustrating! I spent 2 solid days on this stupid bug! I can't find
this bug doing debuggin in VS at all.

Thank you for your help and it was helpful,
Alpha
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top