Visitar URL original
MSSQL connection fails when the database name is typed instead of picked from the dropdown · Issue #1243 · dbcodeio/public · GitHub
Skip to content

MSSQL connection fails when the database name is typed instead of picked from the dropdown #1243

Description

@marvdgf

Description

First of all, thank you for DBCode. We appreciate the plugin very much. Here is a small issue we ran into.

When I create a new Microsoft SQL Server connection, the Database field accepts typed text. If I type the database name by hand, the connection fails. It only works if I pick the database from the dropdown, or load the list with sync/refresh and then pick it.

The field accepts free text, so a typed name that matches an existing database should work the same as one picked from the list.

Steps to reproduce

Open DBCode and add a new connection.
Choose Microsoft SQL Server as the connection type.
Enter the server, authentication and credentials.
Type an existing database name into the Database field by hand (for example MyDatabase). Don't pick it from the dropdown.
Save or connect.
Expected behavior

DBCode connects to the typed database, just as it does when the same name is picked from the dropdown.

Actual behavior

The connection fails. If I open the same connection, pick the same database from the dropdown (after syncing the list if needed) and save, it connects without problems.

Error message

Login failed for %user_name%

Workaround

Don't type the database name. Load the list with sync/refresh and pick the database from the dropdown.

Possible cause (assumption)

The dropdown selection may set a different internal value than the text field, or add one alongside it (for example a database ID or a separate property). A typed name may never reach the connection string. If typed text isn't meant to be supported, the field should be select-only, or show a validation hint.

Environment

DBCode version: 1.38.6
VS Code version: Latest
OS: Windows 11 Enterprise
SQL Server version: Microsoft SQL Server 2019
Authentication type: SQL

Activity

  1. mikeburgh commented on Sep 24, 2026

    @mikeburgh
    Contributor

    Thanks for the detailed report.

    I dug into this and the typed value and the dropdown pick end up as the exact same database setting (you can see it in settings.json, it's just the string).

    The dropdown doesn't store an ID or anything extra, it just fills in the name. So when it fails, SQL Server is getting a name it doesn't accept, and it reports that as "Login failed" (the underlying error is usually "Cannot open database X requested by the login").

    A couple of quick things to check:

    First, compare the casing of what you typed with the name in the dropdown. If the server uses a case-sensitive collation, mydatabase and MyDatabase count as different databases. You can check with SELECT SERVERPROPERTY('Collation'). If it has _CS_ or _BIN in it, the name has to match exactly.

    If you copied the name from somewhere else, try deleting it and typing it again. An invisible character (like a non-breaking space) will cause the same error.

    If the exact same text still fails when typed, could you turn on debug logging and send the output from a failed connect? Steps are here: https://dbcode.io/docs/help-support/debug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions