calling a Crystal Report from C# app that is connected to SQL Server database

  • Thread starter Thread starter sstaviski
  • Start date Start date
S

sstaviski

Guest
Using Visual Studio 2017, Crystal Reports 2016, and SQL Server Express 2017. I designed the Crystal Report directly in Crystal Reports and connected to my development connection to SQL Server. Works fine from the C# app in development, but when I move everything to production (also uses SQL Server Express but is obviously a different machine name), I get an error when crystal reports is called. Even though the C# app is using the correct XML configuration file for production machine, do I still need to code something to tell Crystal Reports to logon to the correct SQL server? Here is my code in calling the report:


frmDepartment FormDepartment = new frmDepartment();

hDeptName = FormDepartment.txtDeptName.Text.ToString();

hDeptName = FormDepartment.txtDeptName.ToString();
hDeptName = "CIT";

ReportDocument cryRpt = new ReportDocument();

cryRpt.Load(Application.StartupPath + "\\DepartmentList.rpt");
crystalReportViewer1.ReportSource = cryRpt;
cryRpt.SetParameterValue("@DeptName", hDeptName);
// cryRpt.SetParameterValue("@name", TextBox2.Text.ToString());
crystalReportViewer1.Refresh();

Continue reading...
 
Back
Top