I have created a database in SQL but when I want to access it by C# but the compiler can't access and open database.
the error is :
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: Cannot open database "Restaurant" requested by the login. The login failed.
Login failed for user 'Milad0007\Milad.H'
Additional information: Cannot open database "Restaurant" requested by the login. The login failed.
Login failed for user 'Milad0007\Milad.H'
Please guide me to solve it.

Joe WilsonPosted Jun 30, 2015, 5:56 PM
Vignesh ManiPosted Jun 30, 2015, 4:19 PM
Joe WilsonPosted Jun 30, 2015, 4:13 PM
Vignesh ManiPosted Jun 30, 2015, 4:11 PM
Joe WilsonPosted Jun 30, 2015, 4:06 PM
Vignesh ManiPosted Jun 30, 2015, 4:05 PM
Joe WilsonPosted Jun 30, 2015, 4:00 PM
Upendra Pratap ShahiPosted Jun 30, 2015, 1:01 AM
Upendra Pratap ShahiPosted Jun 30, 2015, 1:01 AM
Nilesh JadavPosted Jun 30, 2015, 1:00 AM
Try like this:
Go to your database.mdf - - > Press f4 - -> Connection string Copy the whole Connection string. it looks like this :
just change it to like this:
You need to remove the path and make it short like:
C:\Users\Nilesh\Documents\Visual Studio 2010\WebSites\WebSite13\App_Data -- > Remove this
And add this "|DataDirectory|".
After
Hope this works !!
Vignesh ManiPosted Jun 30, 2015, 12:36 AM
Rajeesh MenothPosted Jun 30, 2015, 12:03 AM
RakeshPosted Jun 29, 2015, 11:36 PM
Abhay ShankerPosted Jun 29, 2015, 10:26 PM