I am really frustrated, this is very simple but didn't work with me. I'm trying to connect to my SQL Server which I don't need username and password when running SSMS. My server name is
string connectionString = "Data Source=HP\\SQLEXPRESS;Initial Catalog=Students.mdf;Integrated Security=SSPI;";
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: Cannot open database "Students.mdf" requested by the login. The login failed.
Login failed for user 'HP\Aymen'.
string connectionString = "Data Source=HP\\SQLEXPRESS;Initial Catalog=c:\\Program Files\\Microsoft SQL Server\\MSSQL11.SQLEXPRESS\\MSSQL\\DATA\\Students.mdf;Integrated Security=SSPI;";
The problem solved. It seems that the problem is because I made Entity Framework model before. When I removed it and run the application again everything went fine.