January 28, 2010

ASP.Net Login Errors

"CREATE DATABASE permission denied in database 'master'."

This was the bane of my existence for several days. I scoured the web to see what other people were doing to resolve the issue and I just got the same stuff, the stuff I was doing.
BACKGROUND: I am using SQL SERVER 2005 to host my data and aspnetdb from the ASP.net framework. I already have the ASPNETDB installed. This DB install defaults it DB connections to .\sqlexpress. This I resolved by changing the .\sqlexpress to (local)\. However this only gave me the message above. Again no help from the web. So how did I get it to work?
If you read in the error, the major issue is that the DB exists and can't be overridden. Think about that for a second and then look at your ASP.net configuration connections for LocalSQLServer...
The string will always try to attach the DB. SO I simply gave the LocalSQLServer connection a normal connection.
Open IIS and right click on the website. Select Propeerties. Click on the ASP.net tab and select either Global or Local configuration. Select the LocalSQLServer connection and edit the string to something like this:
Data Source= <servername>;Initial Catalog=Aspnetdb;Persist Security Info=True;User ID=<uname>;Password=<pword>; The key is to remove the section for AttachDatabase and replace with Initial Catalog.
Once I changed this connection it integrated into ASP.net security just fine. I hope this helps someone else from beating their head on the table for days onend wondering why it isn't working.