I pulled an ASPNETDB.MDF file off of a server for a ASP site using Forms authentication to my local machine. I added a new user to the database file using the ASP.NET Website Configuration tool. I uploaded the MDF file back to the server and now I get the following exception whenever I try to log in as any user:
Cannot open user default database. Login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'
I have been googling and read all of the other solutions to this problem here on SO as well and haven’t found anything that works.
The server has SQL Server 2008 on it and that’s what I am using on my local machine with VS 2008 Professional.
My connection string is (linebreaks added for legibility):
<add name="ASPNETDBConnectionString1"
connectionString="Data Source=.\SQLEXPRESS;
AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;
Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient"
/>
I’m new to SQL Server so I am pretty sure I messed something up somewhere.
Any help is greatly appreciated.
All questions about who or what or why regarding the config aside…
Your problem can be deduced from the connection string. That will work locally against sql express but not against sql proper on the server.
The first clue is that only SqlExpress enables User Instances. On Sql proper you will have to attach the mdf.
If that connection string works on your machine while in VS 2008, you have SQL EXPRESS installed. If that connection string works on the server then the server has SQL EXPRESS installed.
If the server does NOT have Sql Express installed and configured to allow user instances, as I would hope it did not, that connection string will result in the login failure exception you are experiencing.
I also wonder about your copy to/from. Typically access will be denied an active mdf, even for copying.
Please confirm Sql versions both client and server side and try to find a previous copy of both web.config files to compare connection strings.