Access issue due to sa account

Jonathan 300 Reputation points
2026-08-21T09:24:27.23+00:00

Hi,

To issue

Microsoft OLE DB Provider for SQL Server Cannot open database "hMailserver" requested by the login.

I can logon on SSMS using the same sa account. I am using Sql server 14.0.1000. Any reason?

SQL Server Integration Services
0 comments No comments

3 answers

Sort by: Most helpful
  1. Deepesh Dhake 835 Reputation points
    2026-08-21T14:00:54.3166667+00:00

    The login is fine. This error means the database couldn't be opened, not that authentication failed. SSMS connects to master by default, so a successful SSMS login doesn't confirm hMailserver itself is accessible.

    Please run:

    SELECT name, state_desc FROM sys.databases;
    

    Then check whether hMailserver is listed, spelled/cased exactly right, and shows ONLINE. If it's missing, offline, or named differently, that's your cause.

    Was this answer helpful?

    0 comments No comments

  2. Erland Sommarskog 136.7K Reputation points MVP Volunteer Moderator
    2026-08-21T12:53:25.08+00:00

    The most likely reason would be that the database hMailserver does not exist.

    When you log in through SSMS, you will connect to your default database, unless you explicitly select a database. The default database for sa is typically master, which always exists.

    When you connect through an application, it's common that the connection string specifies a database explicitly. If you connect and specify non-existing database, connection will fail. Even if you are sa.

    By the way, you are running the release version of SQL 2017. You should download and install the last Cumulative Update, CU31 for SQL 2017 to get access to many bug fixes and enhancements.

    Was this answer helpful?


  3. AI answer

    2026-08-21T09:24:44.55+00:00

    If sa can connect in SSMS but the OLE DB connection fails with Cannot open database "hMailserver" requested by the login, the most likely cause is not the sa password itself, but the database being requested at login time.

    Check these items:

    1. Verify the database name in the OLE DB connection string
      • Confirm that hMailserver exists on the target SQL Server instance.
      • Confirm the connection is going to the correct server and instance.
      • If a named instance is used, include the instance name.
    2. Check whether hMailserver is available
      • If the login’s default database or the database specified in the connection string is offline or unavailable, login can fail even when the same login works elsewhere.
      • In SSMS, try connecting and then explicitly selecting an available database in Connection Properties.
    3. Compare SSMS and application connection targets
      • A common cause is that SSMS is connecting to the correct server, but the OLE DB provider is pointing to a different server or instance.
      • Validate the server name in the connection string carefully.
    4. Test the exact OLE DB connection outside the application
      • Use a UDL file and select the same OLE DB provider.
      • On the Connection tab, enter the server as FQDN and port, for example: tcp:SQLProd01.contoso.com,1433
      • Then select Test Connection.
      • This helps confirm whether the issue is the provider settings or the application configuration.
    5. Review the connection string syntax
      • Make sure it includes the correct server name, database name, user name, and password.
      • If the database name is wrong, or the server is wrong, SQL Server can return the database-open/login failure.
    6. Check SQL Server error details
      • SQL Server Errorlog can show whether the failure is due to:
        • wrong server/instance
        • wrong database name
        • failed to open the database specified in login properties
        • incorrect password

    Since sa works in SSMS, the strongest candidates are:

    • the OLE DB connection string points to a different server or instance
    • hMailserver is specified in the OLE DB connection but is offline, unavailable, or incorrect
    • the application is using different connection properties than SSMS

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.