Login Failed when trying to use SQL database to store wpf data

uzair akhalwaya 1 Reputation point

System.Data.SqlClient.SqlException: 'Cannot open database "StockSystemdb." requested by the login. The login failed.
Login failed for user 'MicrosoftAccount\MyEmail'.'

Any fix?

Azure SQL Database
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,369 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
9,800 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
4,735 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Erland Sommarskog 78,026 Reputation points MVP

    Well, you would need to add MicrosoftAccount\MyEmail as a user in the database StockSytsemDb.

    It could have helped if you had included what troubleshooting you have performed, and some information why you don't expect to get this error.

    0 comments No comments

  2. AmeliaGu-MSFT 13,901 Reputation points Microsoft Vendor

    Hi uzairakhalwaya-2700,

    Welcome to Microsoft Q&A.
    Could you please try to use user 'MicrosoftAccount\MyEmail' to connect to SQL Server database and see if there are any detailed error message?
    And what the connection string are you using?
    Please make sure user 'MicrosoftAccount\MyEmail' exists under database->security->users.

    Best Regards,

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments