Solution for failing to connect to the SQL Server database (failing to establish a database connection)

Source: Internet
Author: User

Problems:

These two days I have learned about ASP. NET users and role management. When using the ASP. NET membership framework 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 XP SP2 + iis5.1 + Visual Studio 2008 + SQL Server 2005 (default instance)

Solution:(Follow these steps to solve the problem)Archerlu)(Modified by me)

1. First, open the SQL Server service in SQL Server Configuration Manager and check whether the SQL Server service and SQL Server expression service are enabled;

2. 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.

3. 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 ).

4. 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)

5. 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)

6. in IIS, choose "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.