Assign global connection string
Posted: Thu 03 Feb 2011 10:17
Hello all,
I do my first steps in ASP.NET.
I have a WebForm in VS2010 with a MySqlDataSource and the connection string I assign in the Page_Load method. But this I have to do for every page. This is not fine.
In C++Builder Desktop application I have a Connection component and this I assign to the several datasources once via designer and not every time via source.
Is this also possible in ASP.NET with your component.
Right now my code is below
Thanks
Thomas
I do my first steps in ASP.NET.
I have a WebForm in VS2010 with a MySqlDataSource and the connection string I assign in the Page_Load method. But this I have to do for every page. This is not fine.
In C++Builder Desktop application I have a Connection component and this I assign to the several datasources once via designer and not every time via source.
Is this also possible in ASP.NET with your component.
Right now my code is below
Code: Select all
protected void Page_Load(object sender, EventArgs e)
{
// ConfigurationSettings.AppSettings("CratemakerDB");
NameValueCollection names = ConfigurationManager.AppSettings;
String value = names.Get("CratemakerDB");
MyDsFirma.ConnectionString = value;
}
Thomas