Friday, December 11, 2009

Error message when you install SQL Server 2005 SP2, SQL Server Express SP2, or SQL Server Express with Advanced Services SP2: "SQL Server Setup failed

A web application that attempts to create a database or read/write to a database using SQL Server Express user instance mode can encounter any of the following errors:

Error message when you install SQL Server 2005 SP2, SQL Server Express SP2, or SQL Server Express with Advanced Services SP2: "SQL Server Setup failed to execute a command for server configuration. CREATE DATABASE failed"

A web application relies on SQL Server Express' user instance mode if either of the following is true:

The application relies on the default "LocalSQLServer" connection string defined in machine.config
The application uses a connection string that contains the following attributes:

"AttachDBFilename=|DataDirectory|xxxxxx.mdf;User Instance=true"

Resolution for Web Application Projects and Websites

For web application projects (WAP) and websites located in a user's Documents Folder hosted under any version of IIS running as NETWORK SERVICE, carry out the following steps:

First confirm that IIS has been configured to run as NETWORK SERVICE. This is the default on IIS6 and IIS7. However if you are running on Windows 7 or Window Server 2008 R2 you will first need to follow the steps above in "Resolution for Windows 7 and Windows Server 2008 R2" to make IIS application pools run as NETWORK SERVICE.
From a command prompt, type net stop iisadmin /y . This will cause any running ASP.NET WAP applications to shutdown.
Exit out of all running Visual Studio instances.
NETWORK SERVICE must be granted Read permission to the top-level Visual Studio folder located in your user's Documents folder. The Visual Studio folder will have different names depending on the version: "Visual Studio 2005", "Visual Studio 2008", or "Visual Studio 2010".
NETWORK SERVICE must be granted both read and write permissions to your project's top-level project folder. For example if your WAP project is called "MyCustomWebProject", then the folder "Documents\Visual Studio 20xx\Projects\MyCustomWebProject" needs to have read and write access enabled for NETWORK SERVICE. Or, if your webiste project is called "MyCustomWebProject", then the folder "Documents\Visual Studio 20xx\Websites\MyCustomWebProject" needs to have read and write access enabled for NETWORK SERVICE.
NETWORK SERVICE must be granted both read and write permissions to the App_Data folder located within your web project's directory structure.

No comments:

Post a Comment