rax313
rax313

Reputation: 88

rebinding a crystal report to a new dataset

I am new to making reports and so far I can make crystal report generate an initial report and the data it displays is correct, but when I try to add parameters and then try to rebind the dataset to crystal report it doesn't seem to work. the data displayed is still the same.

I have tried the following code below in VS2005 and the "built in Crystal Report".

` SiteReport newSiteRpt = new SiteReport();  
             DataSet ds = this.db.fillDS(dateTimePicker1.Value.ToShortDateString(),
                                         dateTimePicker2.Value.ToShortDateString());
             newSiteRpt.SetDataSource(ds);
             newSiteRpt.OpenSubreport("ChartReport").SetDataSource(subReportDS);
             this.crystalReportSiteViewer.ReportSource = newSiteRpt;
             this.crystalReportSiteViewer.Refresh();
           `

What could I be missing here?

thanks in advance.

Upvotes: 1

Views: 567

Answers (1)

rax313
rax313

Reputation: 88

I am answering my own question here.

This thread gave me an idea on what I could be doing wrong.

** (Note : Names of DataSet & DataTables should be same as set in Report Document of Crystal Report during Design Time)**

The report was using a different table name than the one in the dataset.

To check the table name of the dataset you are using you can do:

foreach(DataTable table in dataSet.Tables){ Console.WriteLine(table.TableName); }

Hope this helps someone in the future.

Upvotes: 0

Related Questions