部署水晶报表后如何更改服务器名称和数据库名称 [英] How can I change the server name and database name after deploying a crystal report

查看:76
本文介绍了部署水晶报表后如何更改服务器名称和数据库名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个使用VS 2008和Access数据库在C#.net中编写的应用程序.我正在使用Crystal Reports(基本)进行报告.生成报告的方式,我打开一个Windows窗体,该窗体允许用户选择要报告的内容(日期范围,数据点,分组,总计等),然后生成SQL语句并获取数据需要从数据库中获取数据并将数据集传递到包含CR Viewer的"Windows窗体",然后根据请求的数据打开所需的报告.

在我的发展环境中,一切都很好.

当我将应用程序部署到另一个系统进行测试时,我仍然可以生成数据集,但是当我尝试将数据绑定到报表时,报表将消失并在开发中数据库所在的位置查找数据库系统由于某种原因.尽管我认为它有一个简单的解决方案,但我似乎无法解决它.当我从"Crystal Reports \ database \ Set database location"菜单条创建报告时,它在VS中设置数据库的位置是我在VS中设置的位置.

如何获取报告以仅使用我发送的数据集而不搜索数据库;或获取它以查找用户已在其中安装数据库的数据库(我将此信息保存在配置文件和注册表中)

我已经在Google和论坛中搜索了2天,以寻找解决方案,尽管似乎有些方法可以使用以下命令来修改数据库位置:

"cr.Database.Tables [0] .SetDataSource(databaselocation);"

和其他类似的东西,我什么也帮不了我.

这是我在Windows窗体中使用的基本代码:


I have an application I have written in C#.net using VS 2008 and an Access database. I am using Crystal Reports (basic) for reporting. The way I have generated my reports, I bring up a windows form that lets the user select what they want to report on (date ranges, data points, groupings, totals, etc) and then I generate a SQL statement and grab the data I need from the database and pass the dataset to the "Windows Form" that contains the CR Viewer and then open the required report based on the data requested.

In my development enviornment, everything works great.

When I deploy the application to another system for testing, I can still generate the dataset, but when I try to bind the data to the report, the report goes out and looks for the database at the location where the database was located on my development system for some reason. I can''t seem to get around this although I assume it has a simple solution. The location where it looks for the database is where I set it in VS when I created the report from the "Crystal Reports \ database \ Set database location " menu strip.

How do I get the report to simply use the dataset I am sending it and not search for the database; or get it to look for the database where the user has installed it (I have this information saved in both the config file and the registry)

I have been searching through google and forums for 2 days looking for a solution and although there seems to be ways to modify the database location using commands like:

"cr.Database.Tables[0].SetDataSource(databaselocation);"

and other similar ones, I can''t get anything to work for me.

Here is the basic code I am using in my Windows form:

public Report19(DataSet ds, string startdate, string enddate)
    {
      InitializeComponent();
      CrystalReport25 objRpt = new CrystalReport25();
      objRpt.SetDataSource(ds.Tables[0]);
      objRpt.SetDatabaseLogon("", "NH1admin");
      objRpt.SetParameterValue("FromDate",startdate);
      objRpt.SetParameterValue("ToDate",enddate);
      CRViewer1.ReportSource = objRpt;
      CRViewer1.Refresh();
    }




感谢您提供的任何帮助.




Thanks you for any help you can provide.

推荐答案

看看

这篇关于部署水晶报表后如何更改服务器名称和数据库名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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