Here I will explain about my database connection error in SQL Server if trying to get data by using asp.net.
I have created one database in my Local SQL Server Management Studio in that I created one table and entered some data in that table.
I opened visual studio and created one sample application using asp.net to access the data from the table to achieve this functionality. I written correct code in asp.net and I run application to get data from database at that time I got error like this
Cannot open database "MySamplesDB" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
For solving this error I have searched so many sites they given variety of answers after check all websites I find common and simple solution that is