I am developing an ASP.NET API using VS 2019 Enterprise. It suddenly doesn't let me connect to my SQL server. I tried both a local SQL Server with Windows authentication and a remote SQL Server with password authentication. I never had this problem until today. What could be the problem?
I am also able to connect to both of these SQL Servers through MS SQL Server Management Studio using the same authentication methods.
Error for local SQL Server and Windows authentication:
Microsoft.Data.SqlClient.SqlException
HResult=0x80131904
Message=Cannot open database "myDb" requested by the login. The login failed.
Login failed for user 'DESKTOP-PSCSGS6\MyLocalUsername'.
Source=Core Microsoft SqlClient Data Provider
StackTrace:
at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
Error for remote SQL server with password authentication: (credentials are correct)
Microsoft.Data.SqlClient.SqlException
HResult=0x80131904
Message=Cannot open database "MyDb" requested by the login. The login failed.
Login failed for user 'MyDbUserName'.
Source=Core Microsoft SqlClient Data Provider
StackTrace:
at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
User contributions licensed under CC BY-SA 3.0