How to solve an error in connecting ASP. NET to SQL Server in IIS

Source: Internet
Author: User
Tags sql server management studio

Another way to solve the connection problem is to enable SQL Server Authentication in IIS, and then connect to the string using the user ID and password; or when ASP. NET should
Use the ASP. NET impersonation method when the program runs with another Windows user rather than ASPNET.
To enable the ASPNET account to access the database of ASP. NET applications, follow these steps:

1) start SQL Server Management Studio, specify the name of the SQL Server instance, and log on in Windows Authentication mode.

2) use the grantlogin stored procedure to add Windows users to the SQL Server database. This numerator will assign the ASPNET account connection
Access SQL Server permissions. Note: Replace the MachineName in the command with the Host Name of the local machine.
Exec sp_grantlogin 'machinename \ aspnet'

3) after you grant the SQL Server connection permission to the ASPNET account, you must also grant it the permission to access the database of the ASP. NET application.
Permission. Note: replace DateBaseName with the Database Name of the ASP. NET application:
USE DateBaseName
Exec sp_grantdbaccess 'machinename \ aspnet'

4) Finally, you need to grant the ASPNET permission to access the internal objects of the ASP. NET application database, such as executing the stored procedure, reading and
Modify tables. The simplest way is to assign the db_owner role to the database of an ASP. NET application to the ASPNET account. If the previous steps
You have connected to the database of the ASP. NET application. Enter the following command:
Exec sp_addrolemember 'db _ owner', 'achinename \ aspnet'

Now you can connect to the database in Windows Authentication mode from the Web application.

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.