Login failed for User

Habib ur Rehman 41 Reputation points
2022-06-27T17:45:45.307+00:00

I get "Login failed for User" error in visual basic connection to sql-server. This error occurs when I move my database from one PC to another.
I solve this problem by using same "PC-name" & "User-Name" of my old PC in new one.
How should I avoid this I mean I want to use different "PC-name" & "User-Name" on new system. Note that my Sql Login credentials are same in both New & Old PC still it won't let me login.

Developer technologies | VB
SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories

0 comments No comments

4 answers

Sort by: Newest
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    1 deleted comment

    Comments have been turned off. Learn more

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. CathyJi-MSFT 22,431 Reputation points Microsoft External Staff
    2022-06-28T02:29:10.013+00:00

    Hi @Habib ur Rehman ,

    > I mean I want to use different "PC-name" & "User-Name" on new system. Note that my Sql Login credentials are same in both New & Old PC still it won't let me login.

    Agree with Erland. In addition, please make sure that the user account used in connection string is created in SQL server logins under security folder in new PC .
    215478-screenshot-2022-06-28-102600.jpg
    Please share us more detail error message for analysis.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Was this answer helpful?

    0 comments No comments

  4. Erland Sommarskog 138.7K Reputation points MVP Volunteer Moderator
    2022-06-27T21:58:53.033+00:00

    How should I avoid this I mean I want to use different "PC-name" & "User-Name" on new system. Note that my Sql Login credentials are same in both New & Old PC still it won't let me login.

    I'm not sure that I get this. First you say that you want to use different user-names, and then you say that your SQL login credentials are the same in both?

    Are you using Windows authentication or SQL authentication? What does your connection string look like?

    If you look in the SQL Server errorlog, you will find more details on why connection failed.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.