1

Here is my connection string.

string connectionString = @"Data Source=.\SQLEXPRESS;Database=dbo.Employee; User Id=user1; Password=Password11"; 

I have a database called Employee with a table called [EVUSERS] in the dbo schema.

I have created a database login under sql logins for this username and password, for some reason it wont allow me to login to the server at the connect to server window.

Whenever I try and use the connection string in the form in my C# I keep getting an error

logon failed for 'user1'

I am not sure if its a server side issue I have or a c# side. thanks

15
  • 2
    Have you tried connecting to that database with that user/password combination using SSMS? Commented Jan 22, 2014 at 14:59
  • 2
    I don't think you need the dbo. in front of your Database name. But yes it seems like a username/password issue. Commented Jan 22, 2014 at 14:59
  • 1
    I believe @EvanL is correct. You don't need dbo. in front of your database. The schema relates to your database objects, not the database itself. Commented Jan 22, 2014 at 15:07
  • 3
    @EPOColla, sounds like you created the user but did not enable CONNECT access to the database. Refer to the answer with the article below on how to create a login and grant access. Commented Jan 22, 2014 at 15:09
  • 1
    Try another user, maybe 'sa'. If that works then its definitely the permission for your user. Commented Jan 22, 2014 at 15:33

1 Answer 1

3

The "login failed" error generally means one of few things:

  1. The login doesn't even exist. See the "Create a Login" article on MSDN.
  2. The login doesn't have access to the database, which is also covered in that article.
  3. The password is wrong.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.