I have a solution with 4/5 projects.
I currently have the connection string for my domain project hardcoded in a c# file.
I’d like to put this in a web.config or something. From what I’ve been reading here and elsewhere I should store these connection strings in the web config of the calling application?
If so how do I access it?
When I do something like this in my class library:
ConnectionStringSettingsCollection connectionStrings =
connectionStringsSection.ConnectionStrings;
The type or namespace could not be found, am I missing a reference or something?
There is an existing schema in the
configschema for connection strings.This goes under the
<configuration>element:In your code, you should use
ConfigurationManagerto access them. In order to have the reference to it you need to add ausing System.Configuration;namespace to your file and theSystem.Configuration.dllassembly reference to your project (if not already there).