You are here:

C#/Making Reports in C#

Advertisement


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.
**********************************************

Answer
Hi

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

C#

All Answers


Answers by Expert:


Ask Experts

Volunteer


Srini Nagarajan

Expertise

can answer any kind of questions in ASP.NET, C#, VB.NET, ASP, SharePoint 2007, Coldfusion, Powerbuilder 7.00 / 8.00, JAVA servlets, MS SQL 2000 / MSSQL7, Sybase

Experience

Contact me if you need any custom development on ASP.NET, ASP, Coldfusion, Powerbuilder

©2012 About.com, a part of The New York Times Company. All rights reserved.