Make that personal!

Even though I always used to stick with workstion-os to do my developemtn, some of my development-machines are Windows 2003 servers by now. And as a good server I don’t run SQL-Server Express Edition, instead I run a real SQL-Server.

OK – that being said, I recently wanted to create a simple ASP.Net 2.0 application, which would take advantage of the WebPart-Feature of ASP.Net 2.0. But not only placing WebParts in the code on the page, I also wanted to be able to edit settings of those WebParts from within the browser, and do some other cool stuff.

So I turned Personalization=on of my WebPartManager and for this great trust I put into ASP.Net – all I get in return is a lousy error, stating that something went wrong while access the database for my ASP.Net Settings! That is a real bummer! But luckly the page was already giving some hints: maybe I don’t have SQL-Server Express Edition installed on my machine.

After some irritation – since I do have a SQL-Server, but just not the EE (Express Edition) – I finally figured it out (with some great help from a colleague).

So ASP.Net want’s to create a MDF-file in tha App_Data directory of my web-application and then access that newly create database. But this doesn’t seem to work, when you have something else than the EE installed. So you have to tweak ASP.Net a little to get things done.

First of all, create you own custom ASP.Net Settings DB using aspnet_regsql.exe from the current framework directory (e.g. C:\Windows\Microsoft.Net\Framework\v2.0.57[something]). This will bring up a little wizard, which will guide you through the next steps.

Now you have to point your application to the newly created database. A global connectionstring tells the web-application to look for a local database. To change this behavior, you first have to remove the globally set connectionstring, by adding to your web.config a remove element, and then re-adding a new connectionstring, pointing to your custom database. So the web.config section for connectionsstrings could look like this:

<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data
Source=MyServer;Initial Catalog=aspnetdb;Integrated Security=True;"/>

This should solve any problems.

Leave a Comment.