I was running my application in Visual Studio 2010 Application Server, but now I have changed it to use IIS Local Server, then everything crushed. I am getting following error:
System.Data.SqlClient.SqlException: CREATE DATABASE permission denied in database 'master'.
An attempt to attach an auto-named database for file D:\Code\EMSApplication\EMSApplication.Web\App_Data\ASPNETDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
I have changed the setting of Application Pool of the Default Web Site of IIS to Classic .NET AppPool.
Also changed the Identity of the Classic .NET AppPool to LocalSystem.
I also set the permission of the NETWORK SERVICE to the Full
The connection string is:
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.mdf;Integrated Security=True
But none of them worked. I am still getting that error. Any suggestion will be very helpful to me.
Thanks.
I am using SQL Server 2008 Express which comes with the installation of Visual Studio 2010.
The problem is, pretty clearly, that you already have a database named ASPNETDB attached to that SQL Server instance. My assumption is that the VS development web server is still running, and that is what has the database attached. If so, just shut it down and try an IIS restart, and you should be good. If that doesn't do it, go and download SSMS Express, connect to your local SQLExpress instance, and try to detach the existing database from there.