水晶报表数据源重新映射 [英] Crystal Report Datasource remap
问题描述
我与水晶报表和MS SQL Server的工作。
我需要给点水晶报表重新映射到同一个SQL Server上不同的数据库。是否有这样做的一个自动化的方式,或者说我要重新映射为每个单独的报告?我目前通过添加新的数据连接,然后更新存储过程与指定paramether更改数据库(目录)这样做。此外,remaping后,显示报告的.asp的崩溃是这样的:
I am working with Crystal Reports and MS SQL Server. I need to remap the crystal report to point to a different database on the same SQL Server. Is there an automated way of doing this, or do I have to remap for every single report? I am currently doing this by adding a new data connection, and then updating the stored procedure with the specified paramether to change database(catalog). Also, after remaping, the .asp that displays the report crashes like this:
的Active Server Pages,ASP 0115(0x80004005的)
可捕获错误(E06D7363)在外部对象中发生。脚本无法继续运行。
Active Server Pages, ASP 0115 (0x80004005) A trappable error (E06D7363) occurred in an external object. The script cannot continue running.
在code是:
设置mainReportTableCollection =会议(oRpt)。Database.Tables
Set mainReportTableCollection = Session("oRpt").Database.Tables
For Each mnTable in mainReportTableCollection
With mnTable.ConnectionProperties
.Item("user ID") = "<some_login_name>"
.Item("Password") = "<some_password>"
.Item("DSN") = "<some_DSN>"
.Item("Database") ="<some_Database>"
End With
Next
但是,由于它运行,如果我注释掉最后两个幽会。
It runs, however, if i comment out the last two assignations.
先谢谢了。
此致真实地,西尔维乌。
Yours trully, Silviu.
推荐答案
您会发现以下简称我使用(我简化它的飞行,SUP pressing我们自己的对象和全局变量)的过程。这个程序允许所做的报告在开发时使用有效的SQL Server的原始连接重定向。这是写在VB中,使用2个主要目标:
You'll find hereafter the procedure I use (I simplified it on the fly, suppressing our own objects and global variables). This procedure allows to redirect a report from an original connection used at development time to the active SQL server. It is written in VB and uses 2 main objects:
- 原始报表对象通过Crystal报表的实例开
- 一个ADODB连接成为活动连接(称为P_currentConnection),以当前的SQL Server
这个功能(可能是也一分)查看/打印应用程序中的报表对象之前被调用。它可以复制分发数据库间的报告,用户,这取决于它们的位置,连接到不同的服务器/数据库时使用。
This function (could be also a sub) is called before viewing/printing the report object in the application. It can be used when distributing reports among replicated databases where users, depending on their location, connect to different servers/databases.
Public Function connectReportToDatabase( _
P_report As CRAXDRT.Report)
Dim table As CRAXDRT.DatabaseTable, _
For Each table In P_report.Database.tables
If table.DllName <> "crdb_ado.dll" Then
table.DllName = "crdb_ado.dll"
End If
table.ConnectionProperties.DeleteAll
table.ConnectionProperties.Add "Provider", P_currentConnection.Provider
table.ConnectionProperties.Add "Data source", P_currentConnection.Properties("Data source").Value
table.ConnectionProperties.Add "Database", P_currentConnection.DefaultDatabase
table.ConnectionProperties.Add "Integrated security", P_currentConnection.Properties("Integrated security").Value
table.ConnectionProperties.Add "Persist Security Info", P_currentConnection.Properties("Persist Security Info").Value
table.ConnectionProperties.Add "Initial Catalog", P_currentConnection.Properties("Initial Catalog").Value
table.SetTableLocation table.location, "", P_currentConnection.ConnectionString
table.TestConnectivity
Next table
它可与一过程被调用,例如:
It can be called with a procedure such as:
Dim crystal As CRAXDRT.Application, _
m_report as CRAXDRT.report
Set crystal = New CRAXDRT.Application
Set m_rapport = crystal.OpenReport(nameOfTheReport & ".rpt")
connectreportToDatabase(m_report)
如果您的报告中包含子报表,你也可能需要重定向到活动连接。在这种情况下,你将不得不浏览的所有对象在报表中,检查是报告类型,将其重定向到新的连接的人。我相信你会很开心加入相应的多余的线条,以这种原始的方法。
In case your report includes subreports, You might also have to redirect them to the active connection. In this case, you'll have to browse all objects in your report, check the ones that are of the report type and redirect them to the new connection. I am sure you'll have fun adding the corresponding extra lines to this original procedure.
这篇关于水晶报表数据源重新映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!