From: http://blog.csdn.net/sage425/article/details/6043167
An error occurred while establishing a connection with the server. When you connect to SQL Server 2005, the default setting does not allow remote connection to SQL Server may cause this failure. (Provider: SQL network interface, error: 26-An error occurred while locating the specified server/instance)
Note:An error occurred while executing the current Web request. Check the stack trace information for details about the error and the source of the error in the code.
An error occurred while creating the sqlexpress database file:
The connection string specifies a local SQL Server express instance using the database location in the app_data directory of the application. Because the provider determines that the Application Service database does not exist, it attempts to automatically create the database. To successfully check whether the application service database exists and automatically create an Application Service database, the following configuration requirements must be met:
- If the app_data directory of the application does not exist, the web server account must have read and write permissions on the application directory. This is because if the app_data directory does not exist, the web server account will automatically create it.
- If the app_data directory of the application already exists, the web server account requires read and write permissions on the app_data directory of the application. This is necessary because the Web server account will try to confirm that the SQL Server express database is already in the app_data directory of the application. If the read permission on the app_data directory is revoked from the Web server account, the provider cannot correctly determine whether the SQL Server express database already exists. If the provider tries to create a copy of an existing database, an error occurs. Write access permission is required because the Web
Server account creden.
- SQL Server express must be installed on the computer.
- The process ID of the Web server account must have a local user configuration file. For more information about how to create a local user configuration file for a computer account and domain account, see the README document.
Solution: (aspnetdb is missing in the database) because when using personalized services for webpart, You need to configure a connection string in the web. config file. Solution: 1. Disable the personalized service and modify the attributes of webpartmanager: Personalization-> enabled to false2. If you need to use the personalized service:. run C:/Windows/Microsoft. net/framework/v2.0.50727/aspnet_regsql.exe install the database as prompted. B. in the web. add a connection string under connectionstrings In the config file: <connectionstrings> <remove name = "localsqlserver"/> <Add name = "localsqlserver" connectionstring = "Data Source = localhost; initial catalog = aspnetdb; persist Security info = true; user id = sa; Password = ***** "providername =" system. data. sqlclient "/> </connectionstrings> This section overwrites the default connection string and uses the custom one.