Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cant get Crystal Reports to
Message
From
09/08/2007 14:02:41
 
 
To
09/08/2007 13:04:25
Dave Nantais
Light speed database solutions
Ontario, Canada
General information
Forum:
ASP.NET
Category:
Reporting
Miscellaneous
Thread ID:
01247049
Message ID:
01247092
Views:
25
This message has been marked as the solution to the initial question of the thread.
Thanks for that insight...
how do I "push the actual data into the report"


There are two ways for a report to show data - one is when the report "pulls" from SQL Server (or another data source). I generally don't recommend this method (except for internal applications), as the report file itself may not even "see" the database (in a distributed architecture).

The other way (which I recommend) is the "push" model, where you push dataset/XML data (or even objects) into the report. Basically, you create an instance of the report object, and use the report's object model to push data in.

Here's a very simple example, if your report has a database with just one table, when you designed it...you'd do this at runtime, after you instantiate the report, but before you preview it.
oMyReport.Database.Tables[0].SetDataSource( oMyDataSet.Tables[0]);
Now, that's a simple example. Most reports have more than one table, and some reports have subreports. So what you REALLY want is a generic routine to push ANY dataset into ANY report, regardless of how many subreports you have. So you can do something like this, a generic method called PushReportData...
public ReportDocument PushReportData (DataSet DsReportData, ReportDocument oReport)
{
         this.SetData(DsReportData,oReport);
         foreach(ReportDocument oSubReport in oReport.Subreports) 
            this.SetData(DsReportData,oSubReport);
 
         return oReport;
}


private void SetData (DataSet DsReportData, ReportDocument oReport)
{
            foreach (Table oTable in oReport.Database.Tables)
               oTable.SetDataSource
             (DsReportData.Tables[oTable.Name.ToString()]);

}
Now that you have a generic method called PushReportData, you can call it from anywhere....
PushReportData(oMyInvoiceReport, oMyInvoiceDataSet);

PushReportData(oMyEmployeeListingReport, oMyEmployeeDataSet);
Hopefully you'll get the idea.

Also, 30 seconds of shameless promotion, I have a book and an article on Crystal stuff...


http://www.amazon.com/o/ASIN/1590596889/ref=s9_asin_image_1-1966_g1/105-9963583-2051628?pf_rd_m=ATVPDKIKX0DER&pf_rd_s=center-3&pf_rd_r=1GWAW73KGWAKDMQ936ZQ&pf_rd_t=101&pf_rd_p=265623201&pf_rd_i=507846

http://www.code-magazine.com/article.aspx?quickid=0701031&page=1


Let me know if that helps...

Kevin
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform