带有子报告的crystal report不在生产/测试机器C#winforms上工作
我已经创建了包含8个子报告的crystal report(使用VS 2010)。我创建了存储过程,它填充链接到主报表和子报表的所有转储SQL server表。我的代码在开发机器上运行良好,但当它部署到另一台机器上时,它会抛出以下错误 无法打开连接。带有子报告的crystal report不在生产/测试机器C#winforms上工作,c#,.net,winforms,crystal-reports,C#,.net,Winforms,Crystal Reports,我已经创建了包含8个子报告的crystal report(使用VS 2010)。我创建了存储过程,它填充链接到主报表和子报表的所有转储SQL server表。我的代码在开发机器上运行良好,但当它部署到另一台机器上时,它会抛出以下错误 无法打开连接。 详细信息:[数据库供应商代码17] 无法打开连接。 rpt_reportName{GUID}.rpt 详细信息:[数据库供应商代码17] 下面是我生成报告的代码 ReportDocument crReportDocument; Boo
详细信息:[数据库供应商代码17]
无法打开连接。
rpt_reportName{GUID}.rpt
详细信息:[数据库供应商代码17] 下面是我生成报告的代码
ReportDocument crReportDocument;
Boolean TypesDSReports = false;
clsErrorLog oLog = new clsErrorLog();
static TableLogOnInfo crTableLogonInfo;
static ConnectionInfo crConnectionInfo;
static Tables crTables;
static Database crDatabase;
public static void ReportLogin(ReportDocument crDoc, string Server, string Database, string UserID, string Password)
{
crConnectionInfo = new ConnectionInfo();
crConnectionInfo.ServerName = Server;
crConnectionInfo.DatabaseName = Database;
crConnectionInfo.UserID = UserID;
crConnectionInfo.Password = Password;
crDatabase = crDoc.Database;
crTables = crDatabase.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
{
crTableLogonInfo = crTable.LogOnInfo;
crTableLogonInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogonInfo);
}
//crDoc.Subreports["aa"].co = crConnectionInfo;
}
private void DisplayReportWithSubReport()
{
try
{
ReportDocument crReportDocument = new ReportDocument();
crReportDocument.Load(sReportPath.Trim());
ReportLogin(crReportDocument, clsCustomize.gsPropServerName, clsCustomize.gsPropCurrentDataBaseName, clsCustomize.gsPropDataBaseUserID, clsCustomize.gsPropDataBasePassword);
crReportDocument.Refresh();
CRViewer.ReportSource = crReportDocument;
CRViewer.RefreshReport();
this.Text = sDisplayReportCaption;
if (TypesDSReports == false)
{
crReportDocument.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA4;
}
this.WindowState = FormWindowState.Maximized;
if (HMS.Common.clsConstants.gbPropCloseReportForm == true)
{
crReportDocument.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA4;
if (HMS.clsCustomize.giNoOfPrintCopies == 0)
{
HMS.clsCustomize.giNoOfPrintCopies = 1;
}
crReportDocument.PrintToPrinter(HMS.clsCustomize.giNoOfPrintCopies, false, 1, 1);
HMS.Common.clsConstants.gbPropCloseReportForm = false; //Reset the Flag
this.Close();
}
else
{
this.WindowState = FormWindowState.Maximized;
}
}
catch (Exception ex)
{
oLog.LogError(ex, "", "", "", "");
}
}
开发机器和目标机器都有相同的系统配置。请问问题出在哪里
问候,,
Vikram我不是100%同意这一点,但我非常确定,仅在顶层设置连接信息是不够的。您需要在子报表/表中循环,并对每个子报表/表应用logonInfo
crDoc.Subreports[x].Database.Tables[y].ApplyGonInfo(crTableLogonInfo).我自己找到了解决方案。我在ReportLogin方法中添加了以下代码,它工作得非常好
for (int i = 0; i < crDoc.Subreports.Count; i++)
{
crDoc.Subreports[i].SetDatabaseLogon(UserID, Password, Server, Database);
}
for(int i=0;i
我完全同意Jonathan的观点,我们还需要在子报告级别提供连接信息。我在下面添加了我的代码。