问题描述
我想将报告(.rdlc)添加到我的Web项目中.我需要报表使用对象数据源,而不是直接连接到数据库.
I want to add a Report (.rdlc) to my web projet. I need the report to use an object data source, not directly connect to a database.
我的问题是,当我运行报告向导"时,或者当我向报表中添加新的数据集时,数据源配置向导 仅允许我使用数据库.但是,在一个图书馆项目中,数据源配置向导是完全不同的,并为我提供了多种选择.
My issue is that when I run the "Report Wizard" or when I add a new Dataset to the report, the Data Source Configuration Wizard only allows me to use the database. However, in a library project the Data Source Configuration Wizard is completely different and gives me several choices.
我检查了Visual Studio 2013和2015(社区版)
I checked with Visual Studio 2013 and 2015 (Community Editions)
为什么在将Report(.rdlc)添加到图书馆项目和Web Projet时出现不同的行为?以及如何选择对象数据源和/或将其添加到Web项目?
Why is it that I'm experiencing a different behavior when I'm adding a Report (.rdlc) to a library project and a web projet ?And how can I select and/or add an object Data Source to my web project ?
- 创建新的"Asp.NET Web应用程序".我使用了空模板.
- 添加新项目:报告向导"
- Create a new "Asp.NET Web Application". I used the empty template.
- Add a new item: "Report Wizard"
然后将打开以下窗口:
Then following windows will open:
- 添加类型为类库"的新项目,相同的解决方案.
- 添加新项目:报告向导" (到图书馆项目)
现在,我得到以下屏幕(这是我在Web项目中想要的屏幕):
Now I get this screen (That's the screen I want in the web project):
我注意到的另一个区别是项目"菜单:
Another difference I noted is the Project menu:
在图书馆项目中,我有添加新数据源..."
In the library project I have "Add New Data Source..."
但是在Web项目中没有这样的东西...
But in the web project there is no such thing...
推荐答案
这也是VS2010中的一个现有问题.问题不仅与ASP.Net Web应用程序有关,而且与ASP.Net MVC Web应用程序有关.
It is an existing problem in VS2010 also.The problem is not only with ASP.Net web application but also with ASP.Net MVC web application as well.
参考- 带有对象数据源的Visual Studio 2010本地SSRS报告(.rdlc)
Reference - Visual Studio 2010 Local SSRS Report (.rdlc) with Object Data Source
似乎只有通过非Web项目才能获得不同类型的数据源.
It seems it is only possible to get different types of data sources only through non-web projects.
我建议您创建一个单独的DataLayer库项目.
I suggest you to create a separate DataLayer library project.
即使Microsoft自己也没有提及任何此类限制- https://msdn.microsoft.com/zh-cn/library/w4dd7z6t(v = vs.100).aspx#chooseadatasourcetype
Even Microsoft themselves do not mention any such limitation - https://msdn.microsoft.com/en-us/library/w4dd7z6t(v=vs.100).aspx#chooseadatasourcetype
注意:我检查了VS2010和VS2015(企业版).
Note : I checked with VS2010 and VS2015 (Enterprise Edition).
这篇关于无法使用数据源配置向导在Web项目中添加数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!