SqlConnectionStringBuilder wraps InitialCatalog in double quotes and won't connect #3166
Labels
🐛 Bug!
Issues that are bugs in the drivers we maintain.
🆕 Triage Needed
For new issues, not triaged yet.
When my database name has a [space] in it, the SqlConnectionStringBuilder wraps the InitialCatalog in double quotes. When the resulting ConnectionString() value is used by a SqlConnection a connection exception occurs.
The connection opens fine with:
Data Source=(local);Initial Catalog=Development - Core;Integrated Security=True;Trust Server Certificate=True;Application Name=MyApp;Multi Subnet Failover=True
The connection fails with the SqlConnectionStringBuilder generated string:
Data Source=(local);Initial Catalog="Development - Core";Integrated Security=True;Trust Server Certificate=True;Application Name=MyApp;Multi Subnet Failover=True
Expected behavior
The double quotes should not be added when they are not required and should certainly not 'break' the connection string!
Further technical details
Microsoft.Data.SqlClient version: 6.0.1
.NET target: .NET 9
SQL Server version: SQL Server 2022
Operating system: Windows 11
Additional context
I appreciate that this may be an issue in the SQLConnection itself, if the double-quotes shouldn't affect the connection (even though they aren't required). If it were this would still be an issue in this package.
The text was updated successfully, but these errors were encountered: