System.Data.SqlClient.SqlException: Login failed for user 'MachineName\ASPNET'
I'm not sure how many of you are using MSDE as your backend data store, but Web Matrix inborn work naturally with the MSDE Database. Even in the Guided Tour of Web Matrix (which is a tutorial for Web Matrix user and step-by-step samples for users) also have an appendix specialized in MSDE installation).
"Login Failed for user XXX\ASPNET" is a FAQ in the Forums, I think I saw and moderate this kind of questions over thousands of times. Dave post a FAQ for this subject some times ago, while an ASP.NET Team member - MikePope - answer a question for that problem again recently.
Abstract:
Colt's suggestion to enable impersonation causes ASP.NET to make the request to the SQL Server as the name of the user currently running -- probably you...
Using impersonation works if anyone who hits the site has Windows credentials. For your testing, that works for sure. If you're going to create a site that people might get to via the Internet, though, then impersonation won't work, because users won't have credentials. In that case, you probably don't want to use impersonation. Instead, the app can run in the context of the computer\ASPNET user and you can grant database privileges to that ASPNET user...
Personally, I think this lines of explanation is very clear and easy to understand, the point is that impersonation do work but enable ASPNET weaker account is the more practical for an Internet application. I like this simple English and his sample code in replying so I bookmark and blog it. :)
(The oSQL command and complete script can be found at here)