This article helps you to fix SQL Server Error: 18456, Severity: 14, State: 38, Reason: Failed to Open the Explicitly Specified Database.
Fix Error “Failed to Open the Explicitly Specified Database”
The SQL Server error “Failed to Open the Explicitly Specified Database” indicates that you specified the wrong database name in the connection string or do not have permission to access the specified database.
Check the followings:
Validate the database name in the connection string. The database should be online and accessible for login to connect successfully.
Check whether you have specified the correct database in your connection string or not
Open the login properties in SSMS and verify the followings.
Database permissions: You should have permissions to connect to the database and perform required operations. For example, if you want to write data, you should have db_datawriter permission on a specific database.
Check if you use a default database other than the master database (default). If you specify a default database in login properties and that database is not accessible, your login attempt fails.