CrystalReports在本地运行-部署时找不到表(实际上是存储过程)



我有一些Crystal Reports已经在服务器上运行了好几年了——SQL server 2005、Windows 2008。我们最近将服务器升级为新机器Win 2019,SQL server 2014。应用程序中没有任何更改,只是将其复制到新的设置中。应用程序运行良好;有点";跑现在发生的情况是,报告中的存储过程是";未找到";。棘手的部分是,报告中有表和存储过程,它们都连接在一起。我没有写报告,所以我不知道为什么要这样做。报告的SQL如下所示:(SQL中似乎有2个数据源(

Audit_BSA{CALL"AUDIT_BSA"."dbo"."sp_Diagnosis_Variance_rpt";1(NULL,NULL,NULL(}外部加入sp_Diagnosis_Variance_rpt;1.客户端ID={?Audit_BSA:Audit.Clientid}AND sp_Diagnosis_Variance_rpt;1.auditid={?Audit_BSA:Audit.auditid}

Audit_BSASELECT";客户"CLIENT_NAME"审计"Audit_Period_Desc"审计"AuditID"审计"ClientID";FROM";AUDIT_BSA"dbo"AUDIT"AUDIT";INNER JOIN";AUDIT_BSA"dbo"客户"客户";ON";审计"ClientID"="客户"ClientID";其中";审计"ClientID"={?Audit_BSA:sp_Diagnosis_Variance_rpt;1.客户端ID}AND"审计"AuditID"={?Audit_BSA:sp_Diagnosis_Variance_rpt;1.auditid}

因此,存储的proc似乎返回了一些数据,然后CrystalReports正在连接其他真实的表。除了一个报告外,这些报告返回的数据似乎正在工作。无论哪种情况,都会弹出一个错误,抱怨Crystal找不到存储过程,但显然可以看到真实的表,但只能在新服务器上看到。如果我在我们的DEV机器(即SQL server 2008(上运行该报告,它不会给出该消息。

C#中的应用程序通过循环所有表并分配正确信息的公共代码,用新数据库的凭据替换报表上的数据源。

有人经历过这样的事情吗?

UPDATE:这是在运行时分配DB连接信息的代码:

ReportDocument rpt = new ReportDocument();
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();

// Load the report document from the Session object.
// If it's not there, generate a new report document.
if (this.PageContext.Parent.Context.Session["CATRpt"] == null)
//if (Session["CATRpt"] == null)
{

string is_ReportObjectName = "~/Resources/Reports/" + this.PageContext.Parent.Context.Session["csrrpt"];
string reportPath = Server.MapPath(is_ReportObjectName);
rpt.Load(reportPath);
this.PageContext.Parent.Context.Session["CATRpt"] = rpt;
}
else
{
rpt = (ReportDocument)this.PageContext.Parent.Context.Session["CATRpt"];
}
CrystalReportViewer1.ReportSource = rpt;
rpt.SetDatabaseLogon(MainForm.dbuser, MainForm.dbpwd, MainForm.dbserver, MainForm.dbdb);
//Set the ConnectionInfo properties for logging on to the Database 

//If you are using ODBC, this should be the DSN name NOT the physical server name. If 
//you are NOT using ODBC, this should be the physical server name 
crConnectionInfo.ServerName = MainForm.dbserver;
crConnectionInfo.DatabaseName = MainForm.dbdb;
crConnectionInfo.UserID = MainForm.dbuser;
crConnectionInfo.Password = MainForm.dbpwd;
//This code works for both user tables and stored 
//procedures. Set the CrTables to the Tables collection 
//of the report 
Tables CrTables = rpt.Database.Tables;
// Assign to all tables used by the report
//Loop through each table in the report and apply the 
//LogonInfo information 
foreach (CrystalDecisions.CrystalReports.Engine.Table table in CrTables)
{
crtableLogoninfo = table.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
table.ApplyLogOnInfo(crtableLogoninfo);
table.Location = crConnectionInfo.DatabaseName + ".dbo." + table.Location.Substring(table.Location.LastIndexOf(".") + 1);
}

更新:我们添加了代码来记录Crystal Object Error事件中的任何错误,我们得到:

提供的参数无效。未能从数据库中检索数据。文件中的错误主要诊断代码差异{C2484387-1DD8-46B2-B71E-25C1D6641019}。rpt:数据库的参数无效。

同样,它在我们的开发机器上运行良好,我们还安装了SQL Server 2014以匹配服务器。Dev计算机上没有错误。

所以我们找到了答案-对于其他有问题的人:如果在服务器上安装Crystal Reports 64位运行时,请使用64位ODBC连接。此外,我们不得不使用";SQL Server";ODBC驱动程序而不是"ODBC驱动程序";用于SQL Server的ODBC驱动程序11";驾驶员

最新更新