This is a migrated thread and some comments may be shown as answers.

ObjectDataSource connection problem

2 Answers 116 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Pierre-Alain
Top achievements
Rank 1
Pierre-Alain asked on 29 Sep 2010, 04:55 PM
Hello, 

first here is my sln in VS2010:

- BigBrother.DataAccess project: in there I have a DataService class that is used to expose my data. Accessing the data is used via Entity Framework. Currently, im simply calling a member that is used to fetch a list of Establishments.

- BigBrother.MVC.Intranet: in there I have a full intranet website where I want to serve some reports. I have a report folder where I'm trying to create my first report that lists the Establishments that are fetched from my DataService. 

So here's the error im getting when im checking the preview pane:

An error has occurred while processing Report '':
Exception has been thrown by the target of an invocation.
------------- InnerException -------------
The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.



I know it has something to do with my the connectionString, but ive tried various solutions but none worked...Anyone have been able to do something similar to me?

2 Answers, 1 is accepted

Sort by
0
Massimiliano Bassili
Top achievements
Rank 1
answered on 30 Sep 2010, 09:59 AM
Make sure that your connectionString is present in the actual application as well and not only in the report class library. More information is available here:Using connectionStrings from configuration file

Cheers!
0
Pierre-Alain
Top achievements
Rank 1
answered on 30 Sep 2010, 11:04 AM
The actual application is an mvc web application project called BigBrother.MVC.Intranet and there is a correct connexion string there that allows us to access an other project (a backend data layer called BigBrother.DataAccess).

We solved the problem by adding the connexion string infos in the constructor of our data acces layer class like this :

namespace BigBrother.DataAccess
{
    public sealed class DataService : IDisposable
    {
        public DataService()
        {
            var eb = new EntityConnectionStringBuilder();
            eb.Provider = "System.Data.SqlClient";
            eb.ProviderConnectionString = "Data Source=myprivateserver.com;Initial Catalog=bigbrother;Persist Security Info=True;User ID=myusername;Password=mypassword;MultipleActiveResultSets=True";
            eb.Metadata = @"res://*/DataModel.csdl|res://*/DataModel.ssdl|res://*/DataModel.msl";
            Entities = new bigbrotherEntities(eb.ToString());
        }
...

Normally we don't have to specify any connexion information in our data access class because it is already defined in our web application. As I understand it, the report builder tool is using that connexion string when we develop the reports, but it is otherwise completely useless.
Tags
General Discussions
Asked by
Pierre-Alain
Top achievements
Rank 1
Answers by
Massimiliano Bassili
Top achievements
Rank 1
Pierre-Alain
Top achievements
Rank 1
Share this question
or