Friday, August 24, 2007

Dynamically / programmatically changing connection strings of ASP.NET 2.0 providers at run time

Recently, I've been using .NET web parts and personalization on a project. I am pretty happy with the drag and drop feature and how the personalization works, until I was required to change the connection string of personalization database (Application service database) dynamically on run time, instead of declaring it on web.config. Took hours to find a solution or reference to the issue. Finally, found it out in Scott Gu blog, source code for the built in providers in ASP.NET 2.0, what a relieve!  You can check it in here http://weblogs.asp.net/scottgu/archive/2006/04/13/442772.aspx

So I modify the source code a bit, recompile and change the type of provider in the config file and jobs done.

No comments: