We have a VS2010 solution that includes a web app (the startup project) and a class library for data access. The connection string is stored in the web app in a connectionString.config, which is referenced in the web app's web.config. The existing code in the class library uses System.Data.SqlClient to hit the database. This code gets the connections string via:
ConfigurationManager.ConnectionStrings["OurDbName"].ToString();
There are no connection string settings in the class iibrary, so at runtime this pulls the connection string from the web app's configuration.
I want to add "visual" xsd datasets to the class library. However, to do so you need a connection string defined at design-time, and the designer does not recognize the run-time default configuration in the web app. So as things currently are, to create and work with xsd datasets in the class library, I need to define a separate connection string in there (via the project's Settings window). At least I do if I want the drag/drop and context menu functionality in the dataset designer.
I know how to set the connection string at runtime. None of the several ways I've tried were available during design-time.
Is there a way have a connection string defined somewhere other than the data access class library yet still have the connection available to xsd datasets in the class library at design-time?
I think the first obvious answer is to have the connection configuration in the data access class library and if necessary have other projects reference it there. I'm not at this point able to guarantee that's an option, though.
Thanks!