Click here to Skip to main content
16,016,557 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,

try
{
string spath = AppDomain.CurrentDomain.BaseDirectory;spath += "myReportFileName.rpt";
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(spath);
cryRpt.DataSourceConnections[0].SetConnection("Server Name", "DB Name", true);
cryRpt.DataSourceConnections[0].IntegratedSecurity = true;
cryRpt.SetParameterValue("Field Name", "Value");
cryRpt.RecordSelectionFormula = "Correct Formula";
crystalReportViewer1.ReportSource = cryRpt;crystalReportViewer1.Refresh();
}
catch (System.Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
}

In my system, this code is ok. But in other system, It has error. I installed in all other systems crystal report correctly.

This code was executing with error:
crystaldecisions.crystalreports.engine.reportdocument' threw an exception

Then i executed **CRRuntime_32bit_13_0_3.msi** in client system. That error solved **But** other problem:
After to run code, the "Database Login" dialog is showing, and I don't connect to database automatically, and don't view the report file!!!

please help me, what have to i do?

What I have tried:

To view .rpt file in C# code, dynamically set server and database
Posted
Updated 29-Jan-17 20:21pm

1 solution

I solved my problem. :)
when I was creating the project , the crystalReport version 10 had been installed on my system. therefor I choosed "crystalReportViewer version 10" from Toolbox Item.
I uninstalled version 10 of crystal report and installed version 11. In next step, I deleted crystalReportViewer from toolbox of visual studio then again choosed "crystalReportViewer version 11" from Toolbox Item.

now my project and created exe file, executes correctly in all systam that has crystall report vesion 10 later.

thank you!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900