Click here to Skip to main content
16,020,990 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
foreach (var cString in conectionstring)
{
   conectionString = cString;
   Configuration openWebConfiguration =WebConfigurationManager.OpenWebConfiguration("~");
   ConnectionStringsSection sections = openWebConfiguration.GetSection("connectionStrings") as ConnectionStringsSection;

   if (sections != null)
       {                              
       sections.ConnectionStrings["GihanBConnectionString"].ConnectionString = conectionString;
       ConfigurationManager.RefreshSection("connectionStrings");
       openWebConfiguration.Save();
       //Page.Response.Redirect(Page.Request.Url.ToString(), false); 
       //Response.Redirect(Request.Url.ToString()); 
       }
}


hi friends,
i have used this code to change my connection string at run time.its working.but the problem is,after modify, i cannot enter to the system.is it possible to do?

my purpose is to select database at run time for my asp.net web application.(multiple database for a web application).if some one can help me for this it will great for me.
thank you.
Posted
Updated 13-Aug-12 19:47pm
v3
Comments
AmitGajjar 14-Aug-12 2:00am    
Check if updated user have access on that database.

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900