Click here to Skip to main content
15,940,271 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to save my sql file connection string into the web.config file. but i am having some erros. My database file is located inside the App_Data folder and the name is HOSTEL.
here is the code i am trying to work with:

   <add name="WatcherConStr" connectionstring="Data Source=.\sqlexpress;Initial Catalog=HOSTEL;Integrated Security=True; User Instance=True" providername="System.Data.SqlClient" />

here is the error:

connection Error:Cannot open database "HOSTEL" requested by the login. The login failed. Login failed for user 'DJAMA-PC\Joel Mocke'.

Please, any help ???
Updated 7-Jun-11 7:35am

1 solution

Your SQL databse doesn't recognize the Windows Authentication token you passed.

In short, your connection string is right, your SQL DB doesn't accept Windows Auth, specifically the user you're using to try and login.
Share this answer
Djamanet 7-Jun-11 13:52pm    
Ok, i have change the auth mode to Forms and added user id and password i am now getting this error:
connection Error:Login failed for user 'sa'. The user is not associated with a trusted SQL Server connection.
any idea?
Jpuckett 7-Jun-11 15:37pm    
There are users on your forms auth, and there are users at your DB level. You must provide credentials for a SQL Login with using SQLAuth to access your DB.
Jpuckett 7-Jun-11 15:38pm    
When you open MSSQL there's a "Security" folder on the server. You have to add the login there, and then add that user to the DB Instance under the "Users" area.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900