- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试从 OLEDBSQL
更改我的 Crystal Reports 的提供者至 MSOLEDBSQL
如 OLEDBSQL
不支持TLS 1.2
我的代码:
Private Sub ProcessReport()
Dim crxRpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
crxRpt.Load("D:\RND\Crystal Reports - Connector\CrystallReportConvertVB\SummaryReport.rpt")
ChangeOleDbConnectionInfo(crxRpt, "SERVER", "DBNAME", "MSOLEDBSQL", False, "USERID", "PASSWORD")
End Sub
Friend Shared Sub ChangeOleDbConnectionInfo(ByVal reportDocument As ReportDocument, ByVal server As String, ByVal database As String, ByVal oledbProvider As String, ByVal integratedSecurity As Boolean, ByVal userId As String, ByVal password As String)
Dim boMainPropertyBag = New NameValuePairs2()
Dim boInnerPropertyBag = New NameValuePairs2()
boInnerPropertyBag.Add(New NameValuePair2("Application Intent", "READWRITE"))
boInnerPropertyBag.Add(New NameValuePair2("Auto Translate", "-1"))
boInnerPropertyBag.Add(New NameValuePair2("Connect Timeout", "15"))
boInnerPropertyBag.Add(New NameValuePair2("Data Source", server))
boInnerPropertyBag.Add(New NameValuePair2("DataTypeCompatibility", "0"))
boInnerPropertyBag.Add(New NameValuePair2("General Timeout", "0"))
boInnerPropertyBag.Add(New NameValuePair2("Initial Catalog", database))
boInnerPropertyBag.Add(New NameValuePair2("Integrated Security", If(integratedSecurity, "True", "False")))
boInnerPropertyBag.Add(New NameValuePair2("Locale Identifier", "1033"))
boInnerPropertyBag.Add(New NameValuePair2("MARS Connection", "0"))
boInnerPropertyBag.Add(New NameValuePair2("OLE DB Services", "-5"))
boInnerPropertyBag.Add(New NameValuePair2("Provider", oledbProvider))
boInnerPropertyBag.Add(New NameValuePair2("Tag with column collation when possible", "0"))
boInnerPropertyBag.Add(New NameValuePair2("Trust Server Certificate", "0"))
boInnerPropertyBag.Add(New NameValuePair2("Use DSN Default Properties", "False"))
boInnerPropertyBag.Add(New NameValuePair2("Use Encryption for Data", "0"))
boMainPropertyBag.Add(New NameValuePair2("Database DLL", "crdb_ado.dll"))
boMainPropertyBag.Add(New NameValuePair2("QE_DatabaseName", database))
boMainPropertyBag.Add(New NameValuePair2("QE_DatabaseType", "OLE DB (ADO)"))
boMainPropertyBag.Add(New NameValuePair2("QE_LogonProperties", boInnerPropertyBag))
boMainPropertyBag.Add(New NameValuePair2("QE_ServerDescription", server))
boMainPropertyBag.Add(New NameValuePair2("QE_SQLDB", "True"))
boMainPropertyBag.Add(New NameValuePair2("SSO Enabled", "False"))
Dim conAttributes As New CrystalDecisions.Shared.DbConnectionAttributes()
conAttributes.Collection = boMainPropertyBag
Dim boConnectionInfo = New ConnectionInfo With {
.Attributes = conAttributes,
.DatabaseName = database,
.ServerName = server
}
If Not integratedSecurity Then
boConnectionInfo.UserID = userId
boConnectionInfo.Password = password
End If
Dim myTables As CrystalDecisions.CrystalReports.Engine.Tables = reportDocument.Database.Tables
For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In reportDocument.Database.Tables
Dim myTableLogonInfo As CrystalDecisions.Shared.TableLogOnInfo = myTable.LogOnInfo
myTableLogonInfo.ConnectionInfo.Attributes.Collection.Clear()
myTableLogonInfo.ConnectionInfo.Attributes = boConnectionInfo.Attributes
Next
Dim mySections As CrystalDecisions.CrystalReports.Engine.Sections = reportDocument.ReportDefinition.Sections
For Each mySection As CrystalDecisions.CrystalReports.Engine.Section In mySections
Dim myReportObjects As CrystalDecisions.CrystalReports.Engine.ReportObjects = mySection.ReportObjects
For Each myReportObject As CrystalDecisions.CrystalReports.Engine.ReportObject In myReportObjects
If myReportObject.Kind = CrystalDecisions.Shared.ReportObjectKind.SubreportObject Then
Dim mySubreportObject As CrystalDecisions.CrystalReports.Engine.SubreportObject = CType(myReportObject, CrystalDecisions.CrystalReports.Engine.SubreportObject)
Dim subReportDocument As CrystalDecisions.CrystalReports.Engine.ReportDocument = mySubreportObject.OpenSubreport(mySubreportObject.SubreportName)
Dim mytablessub As CrystalDecisions.CrystalReports.Engine.Tables = subReportDocument.Database.Tables
For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In mytablessub
Dim myTableLogonInfo As CrystalDecisions.Shared.TableLogOnInfo = myTable.LogOnInfo
myTableLogonInfo.ConnectionInfo.Attributes.Collection.Clear()
myTableLogonInfo.ConnectionInfo.Attributes = boConnectionInfo.Attributes
Next
End If
Next
Next
reportDocument.VerifyDatabase()
reportDocument.SaveAs("D:\RND\Crystal Reports - Connector\CrystallReportConvertVB\CrystallReportConvertVB\Rpt-changed3.rpt")
End Sub
我使用以下 Crystal 报表版本:
verifyDatabase()
或 refresh()
在 ReportDocument
将 provider 属性更改回原始属性。 ApplyLogOnInfo()
- 发现它只重置了用户名和密码,而不是提供者。调用此方法还会重置已更改的提供程序。 Not supported within subreports
Friend Shared Function ChangeOleDbConnectionInfoSubReports(ByVal reportDocument As ReportDocument, ByVal server As String, ByVal database As String, ByVal schema As String, ByVal oledbProvider As String, ByVal integratedSecurity As Boolean, ByVal userId As String, ByVal password As String) As ReportDocument
Dim boInnerPropertyBag = New PropertyBag()
boInnerPropertyBag.Add("Application Intent", "READWRITE")
boInnerPropertyBag.Add("Auto Translate", "-1")
boInnerPropertyBag.Add("Connect Timeout", "15")
boInnerPropertyBag.Add("Data Source", server)
boInnerPropertyBag.Add("DataTypeCompatibility", "0")
boInnerPropertyBag.Add("General Timeout", "0")
boInnerPropertyBag.Add("Initial Catalog", database)
boInnerPropertyBag.Add("Integrated Security", If(integratedSecurity, "True", "False"))
boInnerPropertyBag.Add("Locale Identifier", "1033")
boInnerPropertyBag.Add("MARS Connection", "0")
boInnerPropertyBag.Add("OLE DB Services", "-5")
boInnerPropertyBag.Add("Provider", oledbProvider)
boInnerPropertyBag.Add("Tag with column collation when possible", "0")
boInnerPropertyBag.Add("Trust Server Certificate", "0")
boInnerPropertyBag.Add("Use DSN Default Properties", "False")
boInnerPropertyBag.Add("Use Encryption for Data", "0")
Dim boMainPropertyBag = New PropertyBag()
boMainPropertyBag.Add("Database DLL", "crdb_ado.dll")
boMainPropertyBag.Add("QE_DatabaseName", database)
boMainPropertyBag.Add("QE_DatabaseType", "OLE DB (ADO)")
boMainPropertyBag.Add("QE_LogonProperties", boInnerPropertyBag)
boMainPropertyBag.Add("QE_ServerDescription", server)
boMainPropertyBag.Add("QE_SQLDB", "True")
boMainPropertyBag.Add("SSO Enabled", "False")
Dim boConnectionInfo = New CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo With {
.Attributes = boMainPropertyBag,
.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE
}
If Not integratedSecurity Then
boConnectionInfo.UserName = userId
boConnectionInfo.Password = password
End If
For Each subreport As ReportDocument In reportDocument.Subreports
For Each table As CrystalDecisions.ReportAppServer.DataDefModel.Table In reportDocument.ReportClientDocument.SubreportController.GetSubreportDatabase(subreport.Name).Tables
Dim boTable = New CrystalDecisions.ReportAppServer.DataDefModel.Table With {
.ConnectionInfo = boConnectionInfo,
.Name = table.Name,
.QualifiedName = schema & "." & table.Name,
.[Alias] = table.[Alias]
}
reportDocument.ReportClientDocument.SubreportController.SetTableLocation(subreport.Name, table, boTable)
Next
Next
reportDocument.VerifyDatabase()
Return reportDocument
End Function
经验教训
Noticed that, I can not update the driver if the installed CrystalReport Runtime does not match with the Visual studio references (I have taken the DLLs from some Nuget packages that are not official releases). ICouldn't make the code work with Crystal Reports 10.5.3700 that I usedand I updated the runtime to 13.0.2000 (As per this article)
Crystal Reports also have tight rules with the processor architecture.Since I'm using a 32bit version, I have set all the settings in VisualStudio to compile the project as a 32bit app.
最佳答案
您可以通过循环遍历 ConnectionInfos
以编程方式替换报告的连接信息。并更换供应商。有一个(IMO hack-y)关于添加连接/驱动程序信息的解释here它引用了一个帮助编写数据库登录代码的 SAP KB,但文章中的链接已失效(相反,请使用 this one - 这对您的需求可能更有用)。
2020 年 7 月 7 日更新 (包括子报表处理)
// Add these using's (for readability in here):
using RasTables = CrystalDecisions.ReportAppServer.DataDefModel.Tables;
using RasTable = CrystalDecisions.ReportAppServer.DataDefModel.Table;
using RasConnectionInfo = CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo;
// ...
/// <summary>
/// Updates all of the tables contained within the given Crystal Report with new OLEDB connection parameters
/// </summary>
/// <param name="reportDocument">A <see cref="CrystalDecisions.CrystalReports.Engine.ReportDocument"/> of the Crystal Report</param>
/// <param name="server">The new server (Data Source) to use</param>
/// <param name="database">The new database (Initial Catalog) to use</param>
/// <param name="oledbProvider">The new OLEDB provider (see remarks)</param>
/// <param name="integratedSecurity">Whether to use a trusted connection</param>
/// <param name="userId">The new user id to use</param>
/// <param name="password">The new user's password</param>
/// <remarks>Some valid values for a SQL Server OLEDB provider (note: matching vendor components <b>must</b> be installed)<br/>
/// <p>
/// <dt>OLEDBSQL</dt>
/// <dd>Legacy OLE DB provider for Microsoft SQL Server</dd>
/// <dt>SQLNCLI11</dt>
/// <dd>SQL Native Client v11</dd>
/// <dt>MSOLEDBSQL</dt>
/// <dd>latest OLE DB provider for Microsoft SQL Server (use this if TLS 1.0/1.1 are disabled on the SQL Server).</dd>
/// </remarks>
internal static void ChangeOleDbConnectionInfo(ReportDocument reportDocument, string server, string database,
string oledbProvider, bool integratedSecurity, string userId, string password)
{
// boMainPropertyBag: These hold the attributes of the tables ConnectionInfo object
var boMainPropertyBag = new PropertyBag();
// boInnerPropertyBag: These hold the attributes for the QE_LogonProperties
// In the main property bag (boMainPropertyBag)
var boInnerPropertyBag = new PropertyBag();
// Set the attributes for the boInnerPropertyBag
boInnerPropertyBag.Add("Application Intent", "READWRITE");
boInnerPropertyBag.Add("Auto Translate", "-1");
boInnerPropertyBag.Add("Connect Timeout", "15");
boInnerPropertyBag.Add("Data Source", server);
boInnerPropertyBag.Add("DataTypeCompatibility", "0");
boInnerPropertyBag.Add("General Timeout", "0");
boInnerPropertyBag.Add("Initial Catalog", database);
boInnerPropertyBag.Add("Integrated Security", integratedSecurity ? "True" : "False");
boInnerPropertyBag.Add("Locale Identifier", "1033");
boInnerPropertyBag.Add("MARS Connection", "0");
boInnerPropertyBag.Add("OLE DB Services", "-5");
boInnerPropertyBag.Add("Provider", oledbProvider);
boInnerPropertyBag.Add("Tag with column collation when possible", "0");
boInnerPropertyBag.Add("Trust Server Certificate", "0");
boInnerPropertyBag.Add("Use DSN Default Properties", "False");
boInnerPropertyBag.Add("Use Encryption for Data", "0");
// Set the attributes for the boMainPropertyBag
boMainPropertyBag.Add("Database DLL", "crdb_ado.dll");
boMainPropertyBag.Add("QE_DatabaseName", database);
boMainPropertyBag.Add("QE_DatabaseType", "OLE DB (ADO)");
// Add the QE_LogonProperties we set in the boInnerPropertyBag Object
boMainPropertyBag.Add("QE_LogonProperties", boInnerPropertyBag);
boMainPropertyBag.Add("QE_ServerDescription", server);
boMainPropertyBag.Add("QE_SQLDB", "True");
boMainPropertyBag.Add("SSO Enabled", "False");
// Create a new ConnectionInfo object
var boConnectionInfo = new RasConnectionInfo
{
// Pass the database properties to a connection info object
Attributes = boMainPropertyBag,
// Set the connection kind
Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE
};
if (!integratedSecurity)
{
boConnectionInfo.UserName = userId;
boConnectionInfo.Password = password;
}
// Local function will return a copy of the given table using the provided connection info
RasTable CreateBoTableCopy(RasTable originalTable, RasConnectionInfo connectionInfo)
{
// Create a new Database Table to replace the reports current table.
return new RasTable
{
// Pass the connection information to the table
ConnectionInfo = connectionInfo,
Name = originalTable.Name,
QualifiedName = originalTable.QualifiedName,
Alias = originalTable.Alias
};
}
var reportClientDocument = reportDocument.ReportClientDocument;
// Get the Database Tables Collection for your report
RasTables boTables = reportClientDocument.DatabaseController.Database.Tables;
// For each table in the report, set the report's table location to use a newly-modified
// copy of itself with the new connection info
foreach (RasTable table in boTables)
{
reportClientDocument.DatabaseController.SetTableLocation(table, CreateBoTableCopy(table, boConnectionInfo));
}
// Now drop this same science on all of the subreports
foreach (ReportDocument subreport in reportDocument.Subreports)
{
var subreportName = subreport.Name;
foreach (RasTable table in reportClientDocument.SubreportController.GetSubreportDatabase(subreportName).Tables)
{
reportClientDocument.SubreportController.SetTableLocation(subreportName, table, CreateBoTableCopy(table, boConnectionInfo));
}
}
// Verify the database after adding substituting the new table to ensure that the table
// updates properly when adding Command tables or Stored Procedures.
reportDocument.VerifyDatabase();
}
用法:
var newSqlProvider = "MSOLEDBSQL";
if (!string.IsNullOrWhiteSpace(overrideSqlProvider))
ChangeOleDbConnectionInfo(myReportDocument, newServerName, newDatabase, newSqlProvider, false, userName, userPassword);
关于c# - Crystal Reports - 将提供程序从 OLEDBSQL 更改为 MSOLEDBSQL 以通过代码支持 TLS 1.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62038351/
来自 Ruby 世界的我立刻明白为什么 Crystal 选择不实现 for方法。但后来我惊讶地发现 Crystal 确实实现了 for宏的方法。我更惊讶地发现宏不允许可枚举( .each 等)语法(即
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 4年前关闭。 Improve thi
当我创建 Crystal 报表以及将字段和字段添加到数据库时,报表会为我创建的发票输出一个完全空白的报表。你如何调试 Crystal 报告? 您是否设置要输出的标记或标志?某处是否有错误日志描述报告的
我有一个 Crystal 报表功能,该功能要求我修剪以“-”开头的字符,并删除“-”(破折号)之后的其余字符。 例如,我的订单号为00000112345-C43-PJ。 我如何只剪掉“-”右边的所有内
如果我的某些库位于默认目录 lib 之外,我是否可以指出在没有 lib 目录和 shards.yml 的情况下成功编译的需要路径。 最佳答案 是的,更改 CRYSTAL_PATH 环境变量。默认是 $
如何将 Crystal Reports 8.0 迁移到 Crystal Reports 2008? 8.0的存储过程的 Crystal 报表在2008年不执行,有人可以帮忙吗? 我们正在使用 Seag
我们有几个执行相同格式操作的报告(例如,如果值在特定范围内,则显示“通过”或“失败”。) 如果没有 Crystal Reports Server,有没有办法在报表之间共享功能,以便它们不需要重复?我知
如何更改在 Crystal 服务器内运行的 Crystal 报表在运行时使用的数据源(数据库服务器、用户名、密码)? 我有一个 Crystal 服务器并上传了具有设置数据源的报告(SQL Server
我是 Crystal Report 的新手,我一直在想办法解决这个子报表分页问题。我想我知道报告的作用,但我不知道如何解决这个问题。 很难解释所以我上传了这些图片。 我的主要报告: 我的子报告,在 D
我使用的是 Crystal 报表设计器版本 11。 我有一个调用子报表的报表,并且我已经设置了链接参数。子报表正在使用存储过程。 我看不出如何将传递给子报表的参数输入到返回数据的存储过程中。 最佳答案
这是一个普遍的问题。在 Crystal 中, Exception 和 Error 之间有什么区别? 例如,在 JSON 包中,既有 JSON::Error 也有继承自 JSON::ParseExcep
关闭。这个问题需要更多focused .它目前不接受答案。 想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post . 2年前关闭。 Improve this questi
我们如何在 Crystal 报表中为分层组只设置一个字段的缩进? 最佳答案 在 Report 菜单中选择 Hierarchical Grouping Options,将 Group Indent 设置
我需要在Crystal Reports上创建数据透视表。现在我正在使用ODBC连接...但是虽然我知道您可以在CR中创建数据透视表,但我不确定100%如何做到这一点。这里有人知道一个简单的逐步方法吗?
我一直在通过构建它来运行我的 Crystal webapp,然后运行可执行文件。但是,它始终监听端口 3000。 如何构建/运行在 80 和 443 上监听的 Crystal webapps? 我也在
我有 Page Footer()PF A 和 B,每当我抑制 PFa 时,PFb 都会在报告页脚之后向上移动。 把垂直线想象成行号, |Page Header |Details |Report Foo
我想为 Crystal 报表的页眉和页脚行(只有我的数据表而不是完整部分)着色。为该部分着色很容易,但我找不到合适的方法 最佳答案 对于这 3 种方式,您可以实现。 如果页眉/页脚都在与数据不同的部分
我试图像我们在SQL中一样使用IN运算符来过滤 Crystal 报表。在 Crystal 报表中,我试图以这种方式进行操作 ({i_NonPfcIncDetStt.TeamCode} IN('ABC'
大家好,我是 Crystal Reports 的新手。我只想知道什么是 local 和 global 变量。请指出局部变量和全局变量之间的区别。 最佳答案 局部变量:顾名思义,它是创建的公式的局部变量
我是 Crystal 报告的新手,所以这对你来说可能是新手。 我创建了一个交叉表,右侧的行总计。如何添加额外的列来显示行的平均值。我正在使用 Crystal Reports 2008 这是交叉表的粗略
我是一名优秀的程序员,十分优秀!