我已經創建了包含8個子報告(使用VS 2010)的水晶報告。我創建了存儲過程,它填充了與主報告&子報告鏈接的所有轉儲SQL服務器表。我的代碼在開發機器上工作正常,但是當部署到另一臺機器時,它會拋出以下錯誤。水晶報告與子報告不適用於生產/測試機C#winforms
無法打開連接。
詳細信息:[數據庫供應商代碼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, "", "", "", "");
}
}
開發機器和目標機器都具有相同的系統配置。請大家幫助解決問題。
問候, 維克拉姆
我完全同意喬納森,我們還需要提供子報告級別的連接信息。我在下面添加了我的代碼。 – user2092054