gpt4 book ai didi

c# - 通过 Crystal Web 服务以编程方式在 Crystal 服务器上设置 Crystal Report 的数据源

转载 作者:数据小太阳 更新时间:2023-10-29 06:09:02 28 4
gpt4 key购买 nike

如何更改在 Crystal 服务器内运行的 Crystal 报表在运行时使用的数据源(数据库服务器、用户名、密码)?

我有一个 Crystal 服务器并上传了具有设置数据源的报告(SQL Server 2005 托管在服务器 A、用户 A、密码 A 上)。我想安排报告使用来 self 编写的 c# 客户端的不同数据源(托管在 SERVER B、userB、passwordB 上的 SQL Server 2005)运行。

C# 客户端可以使用 Crystal Web 服务提供的对象安排报告在服务器内运行。我一直在使用以下 3 个对象:

BIPlatform
InfoObject
CrystalReport

可以找到有关这些对象的文档 HERE

最佳答案

1/30/2018 - 只是想补充一点,您将需要 CrystalDecisions.ReportAppServer.DataDefModel dll

我有同样的问题,我有一份报告有 MSAccess 数据库连接,我需要将其更改为 SQLServer,花了 2 天时间才弄明白:

            reportDocument = new ReportDocument();
reportDocument.Load(reportFileName);
TableLogOnInfo tableLogOnInfo = ReportClass.GetSQLTableLogOnInfo(connectionProperties.DatabaseSource, connectionProperties.DatabaseName, connectionProperties.UserName, connectionProperties.Password);
for (int i = 0; i < reportDocument.Database.Tables.Count; i++)
{
Table table = reportDocument.Database.Tables[i];
table.ApplyLogOnInfo(tableLogOnInfo);
}

public static ConnectionInfo GetConnectionInfo(string serverName, string databaseName, string userID, string password)
{
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.ServerName = serverName;
connectionInfo.DatabaseName = databaseName;
connectionInfo.UserID = userID;
connectionInfo.Password = password;
return connectionInfo;
}

public static TableLogOnInfo GetSQLTableLogOnInfo(string serverName, string databaseName, string userID, string password)
{
CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag connectionAttributes = new CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag();
connectionAttributes.EnsureCapacity(11);
connectionAttributes.Add("Connect Timeout", "15");
connectionAttributes.Add("Data Source", serverName);
connectionAttributes.Add("General Timeout", "0");
connectionAttributes.Add("Initial Catalog", databaseName);
connectionAttributes.Add("Integrated Security", false);
connectionAttributes.Add("Locale Identifier", "1033");
connectionAttributes.Add("OLE DB Services", "-5");
connectionAttributes.Add("Provider", "SQLOLEDB");
connectionAttributes.Add("Tag with column collation when possible", "0");
connectionAttributes.Add("Use DSN Default Properties", false);
connectionAttributes.Add("Use Encryption for Data", "0");

DbConnectionAttributes attributes = new DbConnectionAttributes();
attributes.Collection.Add(new NameValuePair2("Database DLL", "crdb_ado.dll"));
attributes.Collection.Add(new NameValuePair2("QE_DatabaseName", databaseName));
attributes.Collection.Add(new NameValuePair2("QE_DatabaseType", "OLE DB (ADO)"));
attributes.Collection.Add(new NameValuePair2("QE_LogonProperties", connectionAttributes));
attributes.Collection.Add(new NameValuePair2("QE_ServerDescription", serverName));
attributes.Collection.Add(new NameValuePair2("SSO Enabled", false));

ConnectionInfo connectionInfo = ReportClass.GetConnectionInfo(serverName, databaseName, userID, password);
connectionInfo.Attributes = attributes;
connectionInfo.Type = ConnectionInfoType.SQL;

TableLogOnInfo tableLogOnInfo = new TableLogOnInfo();
tableLogOnInfo.ConnectionInfo = connectionInfo;
return tableLogOnInfo;
}

关于c# - 通过 Crystal Web 服务以编程方式在 Crystal 服务器上设置 Crystal Report 的数据源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2074557/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com