Hi,
I've got a connectionstring problem, I know these kind of questions have been asked thousands of times before but still I cannot figure out what I'm doing wrong.
Here's a simplified structure of my solution:
DataModelClassLibrary
-includes my Entity Framework Model along with a app.config including my db connectionstring like this:
TelerikReportClassLibrary
-here I've defined my reports i've also added a app.config with the same connectionstrings as the app.config
in my DataModelClassLibrary
MyWebProject
-here I've got my actual program and of course it has a web.config again with the same connectionstrings as the app.config
in my DataModelClassLibrary
Now to the problem, if I add a EntityDataSource or a SqlDataSource directly to a report and set it up using one of the
connectionstrings that i've copied to the app.config I'm able to connect to my data and design the report and preview it
within the designer. It also works as expected at runtime.
However recently I wanted to use the ObjectDataSouce so that I could separate out some logic from the report not to make
the report itself too complex and here's where I hit a problem.
I added a class let's say Cars to my TelerikReportClassLibrary which is responsible of retrieving data using my ef model defined in DataModelClassLibrary. I set the report to use a ObjectDataSource and points its select method to a method in the newly created class.
At runtime I can recieve data just fine but if i try to preview the report in the designer I get the following error:
I was able to get around the problem using a technique similar to the one described here:
http://www.telerik.com/community/code-library/reporting/general/use-the-connectionstring-from-your-app-s-config-file.aspx
So that I first checked if it can find the configured connectionstring and if not I manually hardcode one using the EntityConnectionStringBuilder
Is this really my only option? Why can't the report designer find my connectionstring?
Tomas
I've got a connectionstring problem, I know these kind of questions have been asked thousands of times before but still I cannot figure out what I'm doing wrong.
Here's a simplified structure of my solution:
DataModelClassLibrary
-includes my Entity Framework Model along with a app.config including my db connectionstring like this:
<
connectionStrings
>
<
add
name
=
"MyModelEntities"
connectionString
=
"metadata=res://*/Models.MyModel.csdl|res://*/Models.MyModel.ssdl|res://*/Models.MyModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=MYSERVER;Initial Catalog=MYDB;Persist Security Info=True;User ID=MyUser;Password=MyPassword;MultipleActiveResultSets=True""
providerName
=
"System.Data.EntityClient"
/>
</
connectionStrings
>
TelerikReportClassLibrary
-here I've defined my reports i've also added a app.config with the same connectionstrings as the app.config
in my DataModelClassLibrary
MyWebProject
-here I've got my actual program and of course it has a web.config again with the same connectionstrings as the app.config
in my DataModelClassLibrary
Now to the problem, if I add a EntityDataSource or a SqlDataSource directly to a report and set it up using one of the
connectionstrings that i've copied to the app.config I'm able to connect to my data and design the report and preview it
within the designer. It also works as expected at runtime.
However recently I wanted to use the ObjectDataSouce so that I could separate out some logic from the report not to make
the report itself too complex and here's where I hit a problem.
I added a class let's say Cars to my TelerikReportClassLibrary which is responsible of retrieving data using my ef model defined in DataModelClassLibrary. I set the report to use a ObjectDataSource and points its select method to a method in the newly created class.
At runtime I can recieve data just fine but if i try to preview the report in the designer I get the following error:
An error has occurred while processing Report 'MyReport':
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 was able to get around the problem using a technique similar to the one described here:
http://www.telerik.com/community/code-library/reporting/general/use-the-connectionstring-from-your-app-s-config-file.aspx
So that I first checked if it can find the configured connectionstring and if not I manually hardcode one using the EntityConnectionStringBuilder
Is this really my only option? Why can't the report designer find my connectionstring?
Tomas