WPF 客户端应用程序连接到服务器中的数据库。客户端电脑没有安装 MS sql 服务器。所以我在客户端 PC 中安装了 sql server native client 最新版本。但是当我尝试查看报告时,我收到以下错误消息。我仔细检查了 app.config 中的数据库连接字符串,它包含正确的登录信息。
<message>Logon failed.Error in File EmployeeMealSummary {B32AECDC-7F60-4BD9-B2C9-F8153BF2CB5A}.rpt: Unable to connect: incorrect log on parameters.</message>
<source>rptcontrollers.dll</source>
<stackTrace>at CrystalDecisions.ReportAppServer.Controllers.DatabaseControllerClass.SetTableLocation(ISCRTable CurTable, ISCRTable NewTable)
在 CrystalDecisions.CrystalReports.Engine.Table.set_Location(字符串值)
我附上了代码。请帮我解决这个问题。
private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)
{
CrystalDecisions.Shared.TableLogOnInfo crTableLogonInfo;
CrystalDecisions.CrystalReports.Engine.Tables crTables = _report.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
{
crTableLogonInfo = crTable.LogOnInfo;
crTableLogonInfo.ConnectionInfo.LogonProperties.Clear();
crTableLogonInfo.ConnectionInfo.Attributes.Collection.Clear();
crTableLogonInfo.ConnectionInfo.DatabaseName = null;
crTableLogonInfo.ConnectionInfo.ServerName = connectionInfo.ServerName;
crTableLogonInfo.ConnectionInfo.UserID = connectionInfo.UserID;
crTableLogonInfo.ConnectionInfo.Password = connectionInfo.Password;
crTableLogonInfo.ConnectionInfo.DatabaseName = connectionInfo.DatabaseName;
crTable.ApplyLogOnInfo(crTableLogonInfo);
if (crTable.Name == "vEmployee" || crTable.Name == "TB_USER_DEPT" )
{
CenUtility.ErrorLog.CreateLog(new ArrayTypeMismatchException());
crTable.Location = connectionInfo.DatabaseName + ".dbo." + crTable.Location;
}
else
{
crTable.Location = connectionInfo.DatabaseName + ".CafDB." + crTable.Location;
}
}
}