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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Dorababu MekaRank #457 · 5.5K reputationPosted Dec 26, 2012, 2:16 AM EST
{
string name = con.Name;
string connString = con.ConnectionString;
string provider = con.ProviderName;
}
Select the required as per your code
venkata kumarRank #5,034 · 314 reputationPosted Dec 26, 2012, 2:49 AM EST
thanks for reply
but this is finding connections from app.config
first connection not found need to open with second connection
Rohit Sharma96 reputationPosted Dec 26, 2012, 2:59 AM EST
Bryian TanRank #396 · 6.3K reputationPosted Dec 26, 2012, 2:47 PM EST
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
}