I believe many of my friends will write ASP. NET again.ProgramI have encountered this problem since vs. NET 2005 was used. First, I usually use the Web server provided by vs. Net for debugging, so I don't need to consider these things at all. Second, because SQL authentication is used when I write a program. Therefore, this situation is rare even when it is put on IIS. However, if IIS is used for debugging on the local machine and Windows authentication is used, this error will occur.
The following are basic solutions from Microsoft Knowledge Base:
Symptoms
When you create a trusted connection from Microsoft ASP. NET to Microsoft SQL Server, you may receive the following error message:
Login Failed for user 'machinename \ ASPnet (and above iis5.x, the ASP. Net user is 'your machine name \ aspnet ')
For computers that run Internet Information Services (IIS) 6.0, you may receive the following error message:
Login Failed for user 'nt Authority \ Network Service' (on IIS 6.0, ASP. NET is called Network Service)
NoteYou receive either of these error messages specifically when you use integrated security (when you includeIntegrated Security = sspiAttribute in a connection string ).
Resolution
To resolve this issue, use one of the following methods:
•Method 1Programmatically change the security context of the ASP. net worker process to a user who has the correct SQL Server permissions.
•Method 2Change the default configuration of ASP. NET so that the ASP. net worker process starts and runs under the context of a user who has the correct permissions in SQL Server.
•Method 3Grant the correct permissions in SQL server so that the ASPNET account (or NetworkService account, for an application that runs on IIS 6.0) has the appropriate access to the required resources.
NoteThis method will make all the web applications on the server have the corresponding right on the computer that is running SQL Server.
The simplest way is to open SQL Server, add a window login, And put ASP.. Net account added. For convenience, I will give this user the db_owner permission. Of course, you can also give db_creator, but since it is a standalone debugging, I think it's best to make it easier.