Changing Default Database in ASP.NET application

If you have been developing application in ASP.NET and if you were using SQL Server Express edition, then this is not for you … But if you are someone like me who is using SQL Server Standard, Enterprise, Web or Developer edition (not sure about workgroup edition) then this may be the first problem came across you when, you were trying to configure your website from WEBSITE -> configuration option. Everything seem to be look fine, till you click on “Security” setting … and you will be welcomed with screen here…  config_error

Un-doubtly SQL Server Express is first choice for someone who don’t want to be in mess of managing whole dbms or students or may be even many developers are using it as its free and can be a good choice for small web application. And I don’t want to debate on it (or say, I really don’t care smile_devil)

This post is about how to change default database from sql server express to any install sql server edition … But first little bit about IIS and its application pool… IIS is present since Windows NT, though at that time it was very primitive and insecure, but it has been improved greatly from v6 … and v7.5 is the youngest kid in family, which comes with Windows Server 2008 and Windows 7. And Application Pool, I understand it is a pool of requests to access of web application. Which basically handles any request to specific web site / application. Now, even though we were having .NET Framework 3.5 (its 4 now) but it was still using .NET Framework 2.0 as default application pool, v3.5 was not even in the list (but v4 is there) …

I babbled here about application pool because, the option to change database for application depends on that (you will know it soon). The process is two part, at first go to your Windows ->Microsoft.NET folder and choose the application pool version you are using (v2 or v4), yes you need to go either of that installation folder and find “aspnet_regsql.exe” and run it (better if you run as admin) and something like below will pop-up then just like any other MSFT product just point and keep clicking till finish!!! And you are all done. Screenshot of steps are below …

config_2_1 config_2_2 config_2_3

Here I would like to mention that, I really have no idea about which application pool you should use as default and make change accordingly … I mean, upto .NET Framework 3.5, there was just was the only choice but since release of .NET Framework 4 it is also available to set as a default pool, so I have no clue at all which to use, for now, I am using but I have followed these steps for both .NET Framwork 2 and 4 … but choice is yours … in one word .. don’t come after me if something goes wrong smile_tongue

And as a step 2, simply edit your web.config file or database setting for that specific application in IIS Manager. And provide details of your new database and you are all set.

If everything works fine, you will see something like below …


If not, then post your question here. To get more idea about this whole thing, read this post on MSDN

Its just a thought … fingerscrossed

Leave a Reply

Your email address will not be published. Required fields are marked *