如何将 Crystal Reports 指向新数据库 [英] How do I point Crystal Reports at a new database

查看:19
本文介绍了如何将 Crystal Reports 指向新数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Crystal Reports 2008 用户,他拥有 100 多个自定义开发的报表.报告所有查询 Sql Server 数据库 (SQL 2005).
此数据库服务器将被新系统(运行 SQL 2008 R2)替换,现有数据库将移至新服务器.新的数据库服务器将有一个不同的名称(我可以通过 Crystal Reports 连接来寻址),但是,其中一个应用程序也在同时升级.旧数据库 (DB_A) 将在新服务器上恢复以进行历史报告,并创建一个新数据库 (DB_B).新的 DB_B 将有一个非常相似的架构,所以我希望大多数 Crystal Reports 应该能够在新的 DB_B 上运行,除了将报表定义指向新的 DB_B 之外,几乎不需要修改.

I have a Crystal Reports 2008 user that has over 100 custom developed reports. The reports all query Sql Server databases (SQL 2005).
This database server is getting replaced with a new system (running SQL 2008 R2) and the existing databases will be moved to the new server. The new database server will have a different name (which I can address via the Crystal Reports Connections), however, one of the applications is also being upgraded at the same time. The old database (DB_A) will be restored on the new server for historical reporting and a new database (DB_B) will be created. The new DB_B will have a very similar schema, so I would expect that most of the Crystal Reports should be able to run against the new DB_B with little or no modification other than pointing the report definition at the new DB_B.

当然,我的大多数用户都是针对 DB_A 定制开发的报告查询.

Of course, the majority of my users custom developed reports query against DB_A.

我的问题是:如何修改现有的 Crystal Reports 文件以指向新的数据库名称 (DB_B) 而不是旧的数据库 (DB_A)?

My question is: How do I modify existing Crystal Reports files to point at the new database name (DB_B) instead of the old database (DB_A) ?

推荐答案

使用数据库菜单和设置数据源位置"用于更改报表中每个表的名称或位置的菜单选项.

Use the Database menu and "Set Datasource Location" menu option to change the name or location of each table in a report.

这适用于更改数据库的位置、更改为新数据库以及更改报告中使用的单个表的位置或名称.

This works for changing the location of a database, changing to a new database, and changing the location or name of an individual table being used in your report.

要更改数据源连接,请转到数据库"菜单并单击设置数据源位置".

To change the datasource connection, go the Database menu and click Set Datasource Location.

  1. 更改数据源连接:
  2. 从当前数据源"列表(顶部框)中,单击一次您要更改的数据源连接.
  3. 在替换为列表(底部框)中,单击一次新的数据源连接.
  4. 点击更新.
  5. 更改个别表格:
  6. 从当前数据源"列表(顶部框)中,展开您要更改的数据源连接.
  7. 找到您要为其更新位置或名称的表.
  8. 在替换为列表(底部框)中,展开新的数据源连接.
  9. 找到您要更新以指向的新表.
  10. 点击更新.
  11. 请注意,如果表名已更改,旧表名仍会出现在字段资源管理器中,即使它现在正在使用新表.(您可以通过在设置数据源位置的当前数据源中查看表属性的表名称来确认这一点.屏幕截图 http://i.imgur.com/gzGYVTZ.png) 可以从数据库专家的上下文菜单中将旧表名称重命名为新名称 ->选定的表格.
  12. 更改子报告:
  13. 对您可能已嵌入报告中的任何子报告重复上述每个步骤.
  14. 关闭设置数据源位置"窗口.
  15. 任何命令或 SQL 表达式:
  16. 转到数据库"菜单,然后单击数据库专家".
  17. 如果报表设计者使用添加命令"要编写自定义 SQL,它将显示在右侧的 Selected Tables 框中.
  18. 右键单击该命令并选择编辑命令".
  19. 检查该 SQL 是否指定了特定数据库.如果是这样,您可能需要更改它.
  20. 关闭数据库专家窗口.
  21. 在右侧的字段资源管理器窗格中,右键单击任何 SQL 表达式.
  22. 检查 SQL 表达式是否指定了特定的数据库.如果是这样,您可能还需要更改它.
  23. 完成编辑后保存并关闭公式编辑器窗口.
  1. Change the Datasource Connection:
  2. From the Current Data Source list (the top box), click once on the datasource connection that you want to change.
  3. In the Replace with list (the bottom box), click once on the new datasource connection.
  4. Click Update.
  5. Change Individual Tables:
  6. From the Current Data Source list (the top box), expand the datasource connection that you want to change.
  7. Find the table for which you want to update the location or name.
  8. In the Replace with list (the bottom box), expand the new datasource connection.
  9. Find the new table you want to update to point to.
  10. Click Update.
  11. Note that if the table name has changed, the old table name will still appear in the Field Explorer even though it is now using the new table. (You can confirm this be looking at the Table Name of the table's properties in Current Data Source in Set Datasource Location. Screenshot http://i.imgur.com/gzGYVTZ.png) It's possible to rename the old table name to the new name from the context menu in Database Expert -> Selected Tables.
  12. Change Subreports:
  13. Repeat each of the above steps for any subreports you might have embedded in your report.
  14. Close the Set Datasource Location window.
  15. Any Commands or SQL Expressions:
  16. Go to the Database menu and click Database Expert.
  17. If the report designer used "Add Command" to write custom SQL it will be shown in the Selected Tables box on the right.
  18. Right click that command and choose "Edit Command".
  19. Check if that SQL is specifying a specific database. If so you might need to change it.
  20. Close the Database Expert window.
  21. In the Field Explorer pane on the right, right click any SQL Expressions.
  22. Check if the SQL Expressions are specifying a specific database. If so you might need to change it also.
  23. Save and close your Formula Editor window when you're done editing.

然后尝试再次运行报告.

And try running the report again.

关键是首先更改数据源连接,然后是您需要更新的任何表,然后是其他内容.该连接不会自动更改下面的表格.这些桌子就像小鹅,印在他们看到的第一只大型鹅状动物身上.除非您专门手动更改它们,否则它们将继续绕过所有原因和逻辑并前往它们一直去的地方.

The key is to change the datasource connection first, then any tables you need to update, then the other stuff. The connection won't automatically change the tables underneath. Those tables are like goslings that've imprinted on the first large goose-like animal they see. They'll continue to bypass all reason and logic and go to where they've always gone unless you specifically manually change them.

为了更方便,这里有一个提示:您可以显示 SQL 查询";在数据库"菜单中,您将看到直接进入特定数据库的任何表的数据库限定的表名(如Sales"、dbo"、Customers").如果你有很多事情要做,这可能会使狩猎更容易.当我解决这个问题时,我必须更改每个表以指向新数据库中的新表.

To make it more convenient, here's a tip: You can "Show SQL Query" in the Database menu, and you'll see table names qualified with the database (like "Sales"."dbo"."Customers") for any tables that go straight to a specific database. That might make the hunting easier if you have a lot of stuff going on. When I tackled this problem I had to change each and every table to point to the new table in the new database.

这篇关于如何将 Crystal Reports 指向新数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆