开发者

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.crystalRepor开发者_JS百科tSiteViewer.Refresh();
           `

What could I be missing here?

thanks in advance.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜