Cannot add a Data Source in web project using the

2020-08-19 03:37发布

Problem

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.

I checked with Visual Studio 2013 and 2015 (Community Editions)

Questions

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 ?

Steps to reproduce:

  1. Create a new "Asp.NET Web Application". I used the empty template.
  2. Add a new item: "Report Wizard"

Then following windows will open: Data Source Configuration Wizard Of Web Project

  1. Add a new project of type "Class Library" to the same solution.
  2. Add a new item: "Report Wizard" (to the library project)

Now I get this screen (That's the screen I want in the web project): Data Source Configuration Wizard of Library project

Another difference I noted is the Project menu:

In the library project I have "Add New Data Source..."

Project Menu Library Project

But in the web project there is no such thing...

Project Menu Web Project

3条回答
Luminary・发光体
2楼-- · 2020-08-19 03:51

Try View -> Database Explorer. And in the database explorer, right click in some empty space and click Add Connection.

View -> Database Explorer

查看更多
forever°为你锁心
3楼-- · 2020-08-19 03:53

It might not be worth much but the SqlDataSource Wizard searches for existing database connections in Server Explorer and in the configuration file of the current project. I'm wondering if your issue has to do with a web.config file needing to be populated on the web side of things but not for a standard report?

Might not be right but thats just s hot in the dark here.

查看更多
ら.Afraid
4楼-- · 2020-08-19 04:08

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.

Reference - Visual Studio 2010 Local SSRS Report (.rdlc) with Object Data Source

It seems it is only possible to get different types of data sources only through non-web projects.

I suggest you to create a separate DataLayer library project.

Even Microsoft themselves do not mention any such limitation - https://msdn.microsoft.com/en-us/library/w4dd7z6t(v=vs.100).aspx#chooseadatasourcetype

Note : I checked with VS2010 and VS2015 (Enterprise Edition).

查看更多
登录 后发表回答