我为我的 Windows 项目创建了一些 Crystal Reports。当我在 Visual Studio 上运行它们时,它们运行良好。(我正在使用 VS 2010)。但是在我创建安装项目并在客户端 PC 上安装软件后,它们将无法工作。我收到以下错误:
http://tistus.srilanka-erickson.com/errors.html
下面显示的是我用来加载水晶报表的按钮点击事件代码: 第一个 try 子句用于注册报表的自定义输入,同时第二个 try 子句用于手动创建与报表的数据库连接。第三个 try 子句仅用于加载报告。
private void buttonGenerateSecExportRpt_Click(object sender, EventArgs e)
{
CrystalDecisions.CrystalReports.Engine.ReportDocument cryRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
if (comboBoxSecPlateType.Text != "" && comboBoxSecExPlateBrand.Text != "")
{
try
{
dtFrom.Format = DateTimePickerFormat.Custom;
string periodfrom = dtFrom.Value.ToString("yyyy/MM/dd");
dtTo.Format = DateTimePickerFormat.Custom;
string periodto = dtTo.Value.ToString("yyyy/MM/dd");
//cryRpt.VerifyDatabase();
string fullPath = "..\\..\\SecondaryPlateExportReport.rpt";
cryRpt.Load(fullPath);
cryRpt.SetParameterValue("dateFromChecked", dtFrom.Checked);
cryRpt.SetParameterValue("dateToChecked", dtTo.Checked);
cryRpt.SetParameterValue("dtPeriodFrom", periodfrom);
cryRpt.SetParameterValue("dtPeriodTo", periodto);
cryRpt.SetParameterValue("PlateType", comboBoxSecPlateType.Text.Trim());
cryRpt.SetParameterValue("PlateBrand", comboBoxSecExPlateBrand.Text.Trim());
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
DbConnectionInfo.SetConnectionString(ConfigurationManager.ConnectionStrings["con"].ToString());
TableLogOnInfo logOnInfo;
ConnectionInfo connectionInfo;
foreach (Table table in cryRpt.Database.Tables)
{
logOnInfo = table.LogOnInfo;
connectionInfo = logOnInfo.ConnectionInfo;
// Set the Connection parameters.
connectionInfo.DatabaseName = DbConnectionInfo.InitialCatalog;
connectionInfo.ServerName = DbConnectionInfo.ServerName;
if (!DbConnectionInfo.UseIntegratedSecurity)
{
connectionInfo.Password = DbConnectionInfo.Password;
connectionInfo.UserID = DbConnectionInfo.UserName;
}
else
{
connectionInfo.IntegratedSecurity = true;
}
table.ApplyLogOnInfo(logOnInfo);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
crystalReportViewerSecEx.ReportSource = cryRpt;
crystalReportViewerSecEx.Refresh();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Please select both Plate Type and the Brand to Generate the Report!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
我想在客户端 PC 上部署软件后使水晶报告工作。任何建议将不胜感激!