question

uzairakhalwaya-2700 avatar image
0 Votes"
uzairakhalwaya-2700 asked AmeliaGu-msft commented

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

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

Any fix?

sql-server-generalazure-sql-databasewindows-11windows-wpf
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Did you observe the same behavior when you used Windows 10?
Are you able to login with the same credential in the SQL Management Studio?

0 Votes 0 ·

Hi uzairakhalwaya-2700,

How are things going? Were the answers helpful?
Please feel free to let us know if you have any other question. If the post in the thread is helpful, you could kindly accept it as answer.

Best Regards,
Amelia

0 Votes 0 ·
ErlandSommarskog avatar image
0 Votes"
ErlandSommarskog answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AmeliaGu-msft avatar image
0 Votes"
AmeliaGu-msft answered

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,
Amelia


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.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.