I want to make a Front Office, Back Office and a Windows Service to take the Connection String from one place.
I tried to use System.Configuration.ConfigurationManager.ConnectionStrings["SqlServerDatabase"].ConnectionString;
but this works only for websites, the connection string is take from web.config
For Windows Service, I tried System.Configuration.ConfigurationManager.AppSettings["SqlServerDatabase"]
but this will look in app.config, and didn't worked for me
namespace DAL
{
public class DataBase
{
public static string ConnectionString
{
get
{
// return connection string
}
}
....
All 3 applications share the same database access layer called DAL.
It is important to have the Connection String in one place and also to be configurable (not requiring code recompilation)