I have an asp.net website project (not web application) in vb ... call it web1... and a class library project also in vb ... call it web1report. The reports are in the class library as recommended. the report project is referenced in the website project. I have a page in the website w/ a reportviewer pointing to a particular report. The website has a web.config and defined in there is the same connectionstring 'strconn1'. this connectionstring is used by several other pages in the web. it is specifically defined as ...
<
connectionStrings>
<
add name="strconn1" connectionString="Data Source=server123\INS01,4101;Initial Catalog=ABC;Trusted_Connection=Yes" providerName="System.Data.SqlClient" />
</
connectionStrings>
The report uses a sqldatasource and points to a connection string named 'strconn1' ... same as website ... I told the report wiz to save the connection string. I checked 'settings' for class library by r-clicking the project -> properties -> then the settings tab and I can see the connectionstring 'strconn1' listed there.
I can preview the report in VS2008 IDE just fine. but when I try to browse the page w/ the report viewer I get
"Unable to connect to database. Please verify that your connection string is valid; in case you use a connection string from the application configuration file, make sure the name is correct and the connection string settings are present in the configuration file of your application."
now heres the weird part. If I add another connectionstring in the web.config called web1report.My.MySettings.strconn1 ... like ...
<
add name="web1reports.My.MySettings.strconn1" connectionString="Data Source=server123\INS03,4103;Initial Catalog=ABC;Trusted_Connection=Yes" providerName="System.Data.SqlClient" />
then I can view the report
the problem is now i have 2 separate connection strings in my project ... and I dont really like that ...
can someone exlpain why its a problem in the first place, and how i can avoid using 2 separate connectionstrings ?
I also read this forum post and it helps but I thought that as long as I have the same connectionstring name in both projects it should be ok.
is it somehow related to application.settings? im not sure the website has 'settings' only web.config
Any help is appreciated.