将列添加到 Crystal Report 的数据集 (xsd) [英] Adding a column to a DataSet (xsd) for a Crystal Report

查看:22
本文介绍了将列添加到 Crystal Report 的数据集 (xsd)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一份报告,需要向我的一个数据集和 RPT 文件添加一列,但是当我尝试修改数据集时,我收到指定表不存在的错误.当我查看代码时,看起来最初有一个用于此目的的表,但这种方法已被放弃,现在改为使用附加到报告的代码中的 DataSet 来完成.

I am working on a report and need to add a column to one of my datasets and to the RPT file, but when I try to modify the Data Set, I get an error that the specified table doesn't exist. When I look in the code, it looks like there was originally a table used for this purpose, but this approach has been abandoned, and now this is instead being done with a DataSet in code that is attached to the report.

我的问题是我需要在报告中添加这个新列,但我似乎无法以某种方式处理数据,因此我可以将新字段拖到报告中,因为我找不到所需的 DataSet 部分,因为它不像以前那样存在,现在代码中的 DataSet 取而代之.

My problem is that I need to add this new column in the report and I can't seem to get a handle on the data in a way so I can drag my new field onto the report, because I can't find the needed piece of the DataSet because it doesn't exist as it previously did, and the in code DataSet now takes it's place.

有谁能为我指明正确的方向,让我知道如何进行这项工作?

Anyone out there able to point me in the right direction for how to go about making this work?

更新:这大致就是我的数据集如何进入 Crystal Report 的方式

UPDATE: This is roughly how my data set gets to the Crystal Report

private Sub ShowReport()
    Dim dsStatsForPlanned As DataSet = Nothing
    dsStatsForPlanned = DirectCast(Session(CreateSessionKey()), DataSet)
    plannedProductRpt.SetDataSource(dsStatsForPlanned)
End Sub

我在来自 Session 的 DataSet 中添加了我需要的附加字段,但我正在尝试使用 Designer 将这个额外字段添加到报表中,当我尝试刷新或更改数据源时,Designer 告诉我认为该表不存在,大概是因为该表只存在于内存中,并且不直接绑定到 SQL 表.

I have added the additional field that I need in the DataSet that comes in from Session, but am trying to use Designer to get this extra field onto the report, and when I try to refrech or change the Data Source, Designer tells me that the table doesn't exist, presumably because this table exists only in memory, and doesn't tie directly back to a SQL table.

推荐答案

经过几天的挖掘,发现很多没有帮助的信息,我终于在2006年的帖子中找到了我的问题的答案here:

After several days of digging, and finding a lot of information that was not helpful, I finally managed to find the answer to my issue in a post from 2006 here:

http://sstjean.blogspot.com/2006/12/xsdexe-and-msdatasetgenerator-operate.html

我做了什么来解决我的问题:

What I did to fix my problem:

  • 在文本编辑器中手动编辑 XSD 文件并添加我需要的列.这使得它们在 Visual Studio 中查看时出现在我的 XSD 中.
  • 为 XSD 运行指定的自定义工具以重新生成数据集.就我而言,它是 MSDataSetGenerator.这在 VS 的属性"选项卡中列出,我可以在解决方案资源管理器中右键单击 XSD,然后选择运行自定义工具".
  • 打开我的 RPT 文件并运行验证数据库.这终于表明数据库已更改并且正在更新报表,我现在在报表设计器中看到了我的新字段.
  • Manually edit the XSD file in a text editor and add the columns that I needed. This made them appear in my XSD when viewed within Visual Studio.
  • Run the specified Custom Tool for the XSD to regenerate the DataSet. In my case it was the MSDataSetGenerator. This was listed on the Properties tab in VS, and I could right click on the XSD in Solution Explorer and select Run Custom Tool.
  • Open my RPT file and run Verify Databse. This finally indicated that the database had changed and it was updating the report, and I now saw my new field in the Report Designer.

这篇关于将列添加到 Crystal Report 的数据集 (xsd)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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