相信不少朋友再写ASP.NET的程序的时候都有碰到过这个问题的时候,自从用了VS.NET 2005之后,我就很少碰到这个情况了。第一是,我平时写东西都用VS.NET 自带的web server去调试,所以根本不用考虑这些东西。第二是,因为我写程序的时候都用SQL Authentication。 所以,即使是放到了IIS上面也很少碰到过这种情况。但是如果再本机上面用IIS调试并且用Windows Authentication的时候,就会碰到这个错误了。
以下是从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 (再IIS5.x上面,ASP.NET的用户叫 '你机器名字\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' (再IIS 6.0上面,ASP.NET的用户叫Network Service