C#/Making Reports in C#
Expert: Srini Nagarajan - 8/22/2005
Question-------------------------
Followup To
Question -
Hi
I am a beginner at C# programming.
I have a small project with a dataset connected to a sql server database.everything is good.
but I want to create some simple report, and I have installed crystal report 9.
I do this steps:
1- Add a crystal report Item to the project
2- Add a datasource to crystal report and create report in crystal report(and my report name is rpt1.rpt)
3- Add a crystal viewer control to the project
4- the problem is here:
I want to Just write the following two lines on my Forms load event handler.
private void Form1_Load(object sender, System.EventArgs e)
{
rpt1 custReport = new rpt1();
crystalReportViewer1.ReportSource = custReport;
}
but it shows these 3 errors:
1-Cannot find custom tool 'CrystalDecisions.VSDesigner.CodeGen.ReportCodeGenerator' on this system.
2- The type or namespace name 'rpt1' could not be found (are you missing a using directive or an assembly reference?)
3- The custom tool 'CrystalDecisions.VSDesigner.CodeGen.ReportCodeGenerator' failed while processing the file 'BookInsurance_ReportFirst.rpt'.
what is wrong?could you help me pleas?
Thanks.
Answer -
Hi
Where did you keep your 'BookInsurance_ReportFirst.rpt' file?
Happy Programming
-Srini
**********************************************
Dear Srini
thanks for your attention,
sorry,I've typed it wrong,please ignore error number3.I could correct it.
the main problem is number2 , where it can't detect rpt1 class.
what can i do?
thanks.
**********************************************
AnswerHi
Sorry for the delay
rpt1 custReport = new rpt1(); You can't use the rpt1 directly..
try like this
{
ReportDocument rpt = new ReportDocument();
rpt.Load(@"C:\rp1.rpt");
rpt.Database.Tables[0].SetDataSource(ds_xml);
crystalReportViewer1.ReportSource = rpt;
}
Happy Programming!!
-srini