none
The Login Failed for User '<username>' RRS feed

  • Question

  • I am writing an application that will access my SQL 2005 server that is located on another machine. I have the server set up to receive mixed mode logins, but I am still getting this error message. I have TCP/Ip connections active as well as Named pipes. I am can't think of anythign else that will cause this issue. I was able to use it before, but I had to move my server to another machine because I had issues with the previous machine. Can anyone help?

     

    Source = "server=" + wrkServer + "; user=master60pr; password=password ;database=" + wrkDatabase;

     this is the line of code I am using to access the database from the C# program
    Friday, March 14, 2008 4:34 PM

Answers

  • It might be possible that the last setup of SQL Server had that space as part of the password (e.g. the password was actually 'password ') and when you read it to set the password, you were not using an automated system so you read it as it made sense (interpreted the space as not part of the password) and so the original password was 'password ' and now on the new system it is 'password'.  You can verify this with SQL Server Management studio by trying to log into the original server with both variations of the password. If what I have suggested is correct, then it will only succeed with the space present.

    Hope that helps,

    John
    Friday, March 14, 2008 6:10 PM
    Moderator
  • I would like to thank all of you who have answered this post. I figured out the issue. I had the login under the security tab for the database, but I didn't have the login created in the server security tab. I had to delete the one under the database, and create a new one under the server and then add it to the database it is working now. Thanks

    Friday, March 14, 2008 7:24 PM

All replies

  • Marty,

    Try verifying the connection string using Debug.WriteLine and passing the connection string.  This may uncover an issue.

     

     

    Friday, March 14, 2008 5:46 PM
    Moderator
  • I am assuming that master60pr is a SQL Server login.  Does it connect if you remove the space between your password and the semicolon?  It seems to me like it might be interpreted as part of the password and thus authentication would fail.

    Thanks,

    John
    Friday, March 14, 2008 5:46 PM
    Moderator
  • I've removed the space, but it was working before on a different server. Does it matter that previously I had the Visual Studio Program and the SQL server both on the same machine? They are on seperate machines now. Would this make a difference? Also I think it is worth noting that I don't have this issue when I run the program on the machines that the clients are using. Could it be that I haven't set this form of MS SQL server up properly?

    Friday, March 14, 2008 6:07 PM
  • It might be possible that the last setup of SQL Server had that space as part of the password (e.g. the password was actually 'password ') and when you read it to set the password, you were not using an automated system so you read it as it made sense (interpreted the space as not part of the password) and so the original password was 'password ' and now on the new system it is 'password'.  You can verify this with SQL Server Management studio by trying to log into the original server with both variations of the password. If what I have suggested is correct, then it will only succeed with the space present.

    Hope that helps,

    John
    Friday, March 14, 2008 6:10 PM
    Moderator
  • I've tried logging in and it didn't work either way. Now I am confused. I see that I have the login is in the security tab under the database that I am trying to log into, but I noticed that it isn't under the security tab for the server would this make a difference?

    Friday, March 14, 2008 6:18 PM
  • I would like to thank all of you who have answered this post. I figured out the issue. I had the login under the security tab for the database, but I didn't have the login created in the server security tab. I had to delete the one under the database, and create a new one under the server and then add it to the database it is working now. Thanks

    Friday, March 14, 2008 7:24 PM