Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calling Crystal Reports Dynamically in C#
Message
From
05/02/2005 10:20:50
 
 
To
05/02/2005 02:04:32
General information
Forum:
ASP.NET
Category:
Reporting
Miscellaneous
Thread ID:
00984137
Message ID:
00984168
Views:
25
Hey, Mike,

It depends on how you're implementing Crystal.

If you're using CR9/CR10 and you're using the report designer component, it would be something like the following:
string cReportName = "myreport.rpt";
CRAXDRT.Application CrApplication = new CRAXDRT.ApplicationClass();
CRAXDRT.Report oReport;
oReport = CrApplication.OpenReport(@cReportName....)
If you're using the Crystal Managed code DLLs, then it depends on whether you're using a strongly-typed report (the RPT is part of the project), or not (the RPT is not part of the project).

If you're using a strongly-typed report, you can load the report through reflection:
string cReportName = "MyScreen.RPT_MyReport"; // or just "RPT_MyReport"
string DLLName = "MyDLL"; // depending on how your report is set up

System.Reflection.Assembly oDLL;
CrystalDecisions.CrystalReports.Engine.ReportClass oReport;
oDLL = System.Reflection.Assembly.LoadFrom(DLLName);

oReport = (CrystalDecisions.CrystalReports.Engine.ReportClass)oDLL.CreateInstance(cReportName);
myForm.CrystalViewer.ReportSource = oReport;
If you're not using a strongly-typed report, then it's a bit simpler:
ReportDocument oReport = new ReportDocument();
oReport.Load(cFileName);
myForm.CrystalViewer.ReportSource = oReport;
Hope this helps...
Kevin
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform