Custom webpart creation page: An error occurred while creating the sqlexpress database file.

Source: Internet
Author: User
Tags stack trace sql server express connectionstrings
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:

  1. 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.
  2. 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.
  3. SQL Server express must be installed on the computer.
  4. 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.