Solution for Database Configuration failure to connect to SQL Server database (failed to establish database connection) in petshop4.0

Source: Internet
Author: User
Problems encountered when using website management tools for Logon pages

Problems:Go to ASP. NET configuration in the "website" menu of Visual Studio 2005 and click "security". The following error message is displayed:

"A problem may occur in the selected data storage zone because the server name or creden are invalid or the permissions are insufficient. It may also be caused by the absence of the role manager function. Click the following button to redirect to the page where you can select a new data storage area.

The following message may help diagnose the problem: unable to connect to the SQL Server database. "

Test "aspnetsqlprovider" with the following error message:

Failed to establish database connection.
If you have not created an SQL Server database, log out of the website management tool, use the aspnet_regsql command line utility to create and configure the database, and then return to the tool to provideProgram.

System Configuration:Windows 2003 + IIS6 + Visual Studio 2005 + SQL Server 2005 (default instance)

Solution:1. Open the SDK command prompt (all programs -- Microsoft. NET Framework SDK V2.0 -- SDK command prompt. You can also open the vs command prompt), enter aspnet_regsql, and ASP will pop up. net SQL Server Installation Wizard, click Next, click "Configure SQL Server for application services", click Next, use the database <default> (aspnetdb), and click Next to complete.

2. Open Visual Studio 2005 and choose tools> Options> database tools> data connection> SQL server instance name (empty by default ), change to your server name (the default Instance name is your computer name ).

3. In Visual Studio 2005, the tool --> connect to the database --> server name (enter the server you just entered). You can select windows or SQL Server for authentication as required, then select the aspnetdb database. After the test is OK, click "advanced" to copy the bottom line of the dialog window (for example, if you select "use SQL Server Authentication ", the copied statement is similar to Data Source = server; initial catalog = aspnetdb; user id = SA)

4. Open IIS: default website --> properties --> Asp. net --> edit global configuration --> General --> click "connect string manager" "localsqlserver", click Edit, and then clear the strings, paste the string copied in step 1. If you select SQL Server Authentication in step 2, you must manually enter "; Password = sa" in the back. Of course, the SA following will be replaced with your password, and then confirm. If Step 1 is for Windows authentication, paste it and save it. --> application. (If SQL Server authentication is selected in step 1, the modified connection string is similar to Data Source = server; initial catalog = aspnetdb; user id = sa; Password = SA)

5. Go to IIS: default website --> properties --> Asp. Net --> edit global configuration --> authentication --> select "enable role management" --> OK.

Related Article

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.