对于我们的报告环境,我们允许用户“在线”运行报告(代码基于CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocument)或“离线”,后者直接在Business Objects服务器上安排它们。此代码基于CrystalDecisions.Enterprise.Desktop.Report。
对于在线报告,我们可以使用以下代码以编程方式设置提供程序:
If crTableNew.ConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE Then
crLogonInfo = CType(crAttributes("QE_LogonProperties"), PropertyBag)
crLogonInfo("Data Source") = serverName
crLogonInfo("Initial Catalog") = databaseName
crLogonInfo("Provider") = "SQLNCLI11"
End If
但是,用于脱机的等效代码似乎不会公开"Provider“属性。等价的对象大致如下:
CrystalDecisions.Enterprise.Desktop.Report.ReportLogons.Item(tableIndex),但那里的属性似乎都不是Provider。
有人能帮上忙吗?
发布于 2018-08-10 07:14:59
与LoginInfo提供程序属性最接近的对应ReportLogon属性是ServerType属性。但是,我不认为您需要它来设置数据库凭据。
你也许可以这样做
foreach(ReportLogon reportLogon in reportLogons)
{
reportLogon.UseOriginalDataSource = false;
reportLogon.CustomServerName = serverName;
reportLogon.CustomUserName = userId;
reportLogon.CustomPassword = password;
reportLogon.CustomDatabaseName = databaseName;
foreach(TablePrefix tablePrefix in reportLogon.TableLocationPrefixes)
{
tablePrefix.MappedTablePrefix = databaseName + ".dbo.";
tablePrefix.UseMappedTablePrefix = true;
}
}
循环通过TableLocationPrefixes可确保所有被引用的表或存储过程都与登录凭据中指定的数据库相关联。
https://stackoverflow.com/questions/51748883
复制相似问题