Link to home
Start Free TrialLog in
Avatar of cranedj
cranedj

asked on

Problems with C# and Crystal Report integration

I'm using Visual Studio C# .NET, and have created a program that does basic data retrieval from an SQL Database.  One of the requirements of the program is to create reports based off the data, so I'm trying to figure out Crystal Reports to do it.  However, I've tried setting it up, and I keep running into this problem:


Load Report Failed - "CrystalDecisions.CrystalReports.Engine.LoadSaveReportException"


I created the report within the .NET project, and set up a ReportDocument within the form with the CrystalReportViewer, and set the report source to the ReportDocument.  The report itself is set to 'embedded resource'

From everything I can figure out, my program crashes as soon as the ReportDocument object is added to my project.  Specifically, it crashes when it hits the print properties for the ReportDocument.  I tried simply removing those properties, and it did stop crashing, but the program still refused to load the report.

I have also tried doing it programmatically, using this basic setup in the Load for the form  -  DriversByLocation.ReportSource = new cr_drivers_by_location();"  -  where DriversByLocation is the CrystalReportViewer and cr_drivers_by_location is the the embedded report.  This didn't cause the program to crash, but the report will still not load.

I am at a complete loss in trying to figure this out, and all the documentation I've been able to find doesn't cover this error, besides telling me that the program can't open the report.  I would prefer to keep the reports embedded in the program, so that I don't have to deal with external report files.  Any help?
Avatar of msdixon
msdixon

i haven't had much success using crystal... especially when it's using their objects for dynamic report creation. the only way i was able to get it configured properly was to contact thier developer support. they should be able to get you set up (although free developer support is a lower priority than subscription based support).
Avatar of cranedj

ASKER

A small update here - I read in some documentation that instantiating an instance of the report in the form that has the report viewer is another method of binding the data to the viewer control.  I set it up this way:

//Instantiate the report
cr_drivers report = new cr_drivers();

//Bind the control to the report
cv_drivers.ReportSource = report;

I've gotten beyond causing the program to crash.  However, the program still absolutely refuses to view the report, and keeps giving me the "Report Load Failed" error message with no details for fixing the error.  All I get is a popup that says it couldn't load, and an OK button.
Avatar of cranedj

ASKER

I apparently solved the problem myself, although it doesn't make any sense.  I just created a new project, and made a form that accessed a report through the crystal report viewer.  Then I copied and pasted all my code files and forms over to my new project, and changed the namespace.  I changed none of my code, and now it magically works.  Gotta love consistency.....
gotta love crystal reports... if it WORKED
Avatar of cranedj

ASKER

Since I came up with a solution myself, I guess this question should be closed.  Not sure if this is where I do it or what.
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial