The first MDF file was in the AppData folder, and the application was working fine when I added the MDF file to the SQL server. I can execute the query but when I try to use it from the asp.net application it gives the following exception.
The user can not open the default database, login failed. User 'Domain \ Username'
So if I understand correctly, then you Do not specify but instead you have attached the database 'for real' to the existing SQL Server instance.
Because now you are not included with your own personal instance, your application has the appropriate credentials to connect to SQL Server example where you attach the database, the correct solution depends on many factors, but The possible answers are as follows:
- Create a SQL Server login for ASP Ap Pool Identity and grant proper access to this database in the required database. Use to create login [domain user] from windows and create user [domain user]. For better credit, for an additional pool, add the API pool identity to a security group and give this security group the necessary permissions.
- Change the App Pool identity to an uncertainty that has the proper permissions already approved
- If ASP application uses impersonation and SQL Server frequency from ASP application on a different machine If so, make sure that your ASP application pool is allowed to do.