I had it working before. Only change I did is exporting database by generating script and importing it in server.
Web server: IIS / ASP.NET web app
<add key="ConnectionString" value="Data Source=SERVER; Initial Catalog=tkl;Persist Security Info=True; User ID=tkl;Password=PASS; Connection Lifetime=150; Connect Timeout=150; Pooling=true;Min Pool Size=20;Max Pool Size=500" />
2020-09-27 05:23:44.6361|ERROR|System.Data.SqlClient.SqlException (0x80131904): Cannot open database "tkl" requested by the login. The login failed. Login failed for user 'tkl'. at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)
User 'tkl' exists in both TKL database and on SQL Server . I am not sure what is wrong here. probably I need to set some permissions. Any help is appreciated.
Login failed for user 'tkl'. Reason: Failed to open the explicitly specified database 'tkl'. [CLIENT: ]
Both windows and SQL authentificaiton are enabled. I can try to post 'tkl' user object permissions as well.
The Error is telling you that the
LOGIN does not have access to the database you are trying to connect to. Just because a database has a
USER with the same name as the name of a
LOGIN on the server, does not mean that that
LOGIN has access to the database.
USER objects are mapped to
LOGIN objects via the SID, not the name. This means you could have 2 objects, with the different names mapped to each other, and 2 objects with the same name not mapped to each other.
Most likely, here, you just need to
USER to correct the mapping:
USE YourDatabase; GO ALTER USER tkl WITH LOGIN = tkl;
User contributions licensed under CC BY-SA 3.0