RDLC - 在VS2010中添加数据源

发布于 2024-10-09 17:34:23 字数 331 浏览 0 评论 0原文

问候。

我有一个 RDLC 文件,并且想向其中添加数据源,尽管到目前为止还没有任何运气。数据源是我自己编写的自定义类(只是补充一下,我们一直这样做)。我们最近转换为 VS2010 RDLC 格式,这导致了一些问题,但我们对实现进行了一些更改,解决了更主要的问题。

因此,回到当前的问题,当我尝试将数据源添加到 VS2010 中 RDLC 视图中的 DummyDataSource 列表时,它什么也没做,但是它确实将数据源添加到数据源列表中,但您可以' t 从 RDLC 视图的下拉列表中选择它,这意味着我根本无法添加数据源。

有人遇到过这个问题吗?有什么需要我检查的吗?我满怀热情地寻找,但没有运气。

Greetings.

I have an RDLC file and am wanting to add a data source to it, although without any luck so far. The data source is a custom class written by myself (just to add, we do this all the time). We recently converted over to the VS2010 RDLC format which caused some problems, but we've made some changes to our implementation that workaround the more major issues.

So, back to the issue at hand, when I attempt to add my data source to the DummyDataSource list in the RDLC view in VS2010 it just does nothing, however it does add the data source to the list of data sources, but you can't select it from the drop-down list in the RDLC view which means I can't add the data source at all.

Has anyone come across this problem? Is there anything I need to check? I've searched with fervour and had no luck.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

怪我闹别瞎闹 2024-10-16 17:34:23

这里似乎有一些黑魔法正在发生。或者至少我还没有弄清楚让这一切可靠地发生的所有咒语。

我想我也遇到了类似的问题。不确定这是否对您有帮助,但这就是我解决这个问题的方法。

在VS2010报表设计器中,使用“视图”->“报表数据”来显示“报表数据”窗格。

单击“新建”按钮并选择“数据集...”以打开“数据集属性”对话框。

命名您的数据集,如果您以前这样做过,您可能知道这里的数据集名称需要与绑定 ReportDataSource 时代码中提供的名称匹配。

我刚刚尝试的新部分是单击“数据源”下拉列表旁边的“新建...”按钮。生成的向导将引导您选择程序集和 CLR 类(使用复选框选择您的类)。

向导完成后,我的新数据集就会出现。

需要注意的一件事:我第一次尝试重现此问题时,向导完成时没有添加我的数据集。我回到我的类定义并用 [DataContract][DataMember] 属性装饰它,然后重新运行向导,它似乎工作得很好。

也许有更深入知识的人可以评论为什么这些属性使这项工作有效,或者为什么没有它们向导会默默地失败。

There seems to be a bit of black magic going on here. Or at least I haven't figured out all of the incantation to make this happen reliably.

I think I was having a similar problem. Not sure if this will help you, but here's how I got around it.

In the VS2010 report designer, use view->Report Data to show the Report Data pane.

Click the New button and choose Dataset... to get the Dataset Properties dialog.

Name your Dataset, if you've done this before, you probably know that the dataset name here needs to match the name provided in code when you bind your ReportDataSource.

The new part that I just tried, is to click the New... button next to the Data source drop down list. The resulting wizard walks you through selecting your assembly and CLR class (use the checkbox to select your class).

When the wizard finished, my new dataset appeared.

One thing to note: The first time I tried to reproduce this, the wizard completed without adding my dataset. I went back to my class definition and decorated it with [DataContract] and [DataMember] attributes and then re-ran the wizard and it seemed to work great.

Perhaps someone with deeper knowledge can comment on why those attributes make this work, or why the wizard fails silently without them.

一指流沙 2024-10-16 17:34:23

您的数据源对象必须包含本机数据类型作为类的属性,否则它不允许您添加它。有趣的是,呃!

Your data source object must include a native data type as a property on the class, otherwise it doesn't let you add it. Funny, eh!

远昼 2024-10-16 17:34:23

我无法添加数据源,按照向导(新按钮)操作后,数据源没有出现在下拉列表中。
我所做的是添加一个具有原始类型 VS 类的属性,然后继续显示正确​​的数据源。

奇怪的是必须这样做,但我找到了另一种方法。

I could not add the datasource, after following the wizard (new button) the data source did not appear in the drop downlist.
What I did was add a property with a primitive type VS class and then proceeded to show the correct data source.

Strange to have to do this, but I found another way.

故笙诉离歌 2024-10-16 17:34:23

如果您使用存储过程,请使用不使用源表/函数的一行选择替换过程中的所有内容。我无法让它与从临时表或普通表返回数据的存储过程一起使用。

If you are using a stored procedure, replace everything inside the procedure with one row select using no source tables/functions. I couldn't get it working with a stored procedure that returned data from temp table or normal table either.

情泪▽动烟 2024-10-16 17:34:23

当您在存储过程中从临时/内存表中进行最终选择时,我已经看到这种情况发生。您必须通过添加虚拟选择 0 AS mycol1int、'' AS mycol2string 等来伪造设计器。创建数据集后,您可以删除该虚拟选择。 VS 中另一个奇妙、精彩的功能!他们拥有数据库,他们拥有 IDE,但是......

I have seen this happen when your final select in a Stored Procedure pulls from a temp/memory table. You have to fake the designer out by adding a dummy select 0 AS mycol1int, '' AS mycol2string, etc. Once you have created the Dataset, you can then remove that dummy select. Another marvelous, fabulous feature in VS! They own the DB, they own the IDE, but...

爱冒险 2024-10-16 17:34:23

如果添加的数据源对象未显示在 ReportData 上,则:
1.右键单击rdlc,然后单击打开方式
2.选择xml编辑器
3. 手动添加您需要的数据集。

刷新 ReportData 后,您将在列表中看到数据源对象。

If added data source object is not shown on ReportData then:
1. Right click on rdlc and click open with
2. Select xml editor
3. add your needed dataset by hand.

After this refresh ReportData and you will see the datasource object on the list.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文