can any one help me
how to change connections string at run time
current is working with first connection string. run time i need to change second connetion when first connection not found
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Bryian TanPosted Dec 26, 2012, 7:47 PM
I'm not sure how your application using the setting and I assumed that you only have two connection in the app.config. If that the case, you can try something like
if (System.Configuration.ConfigurationManager.AppSettings["ConnectionString1"] != null)
{
//use ConnectionString1
}
else
{
//use ConnectionString2
}
Rohit SharmaPosted Dec 26, 2012, 7:59 AM
venkata kumarPosted Dec 26, 2012, 7:49 AM
thanks for reply
but this is finding connections from app.config
first connection not found need to open with second connection
Dorababu MekaPosted Dec 26, 2012, 7:16 AM
{
string name = con.Name;
string connString = con.ConnectionString;
string provider = con.ProviderName;
}
Select the required as per your code