You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// See https://aka.ms/new-console-template for more informationusingMicrosoft.Data.SqlClient;varconn=newSqlConnectionStringBuilder();try{Console.WriteLine("Set Encrypt to SqlConnectionEncryptionOption type");conn["Encrypt"]=SqlConnectionEncryptOption.Strict;}catch(Exceptione){Console.WriteLine(e);}try{Console.WriteLine("Set Encrypt to boolean false");conn["Encrypt"]=false;}catch(Exceptione){Console.WriteLine(e);}Console.WriteLine(conn.ConnectionString);
Prints the following:
Set Encrypt to SqlConnectionEncryptionOption type
System.ArgumentException: Invalid value for key 'Encrypt'.
at Microsoft.Data.Common.DbConnectionStringBuilderUtil.ConvertToSqlConnectionEncryptOption(String keyword, Object value)
at Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ConvertToSqlConnectionEncryptOption(String keyword, Object value)
at Microsoft.Data.SqlClient.SqlConnectionStringBuilder.set_Item(String keyword, Object value)
at Program.<Main>$(String[] args) in E:\git\sqlenc\Program.cs:line 8
Set Encrypt to boolean false
System.ArgumentException: Invalid value for key 'Encrypt'.
at Microsoft.Data.Common.DbConnectionStringBuilderUtil.ConvertToSqlConnectionEncryptOption(String keyword, Object value)
at Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ConvertToSqlConnectionEncryptOption(String keyword, Object value)
at Microsoft.Data.SqlClient.SqlConnectionStringBuilder.set_Item(String keyword, Object value)
at Program.<Main>$(String[] args) in E:\git\sqlenc\Program.cs:line 17
Given that there's client code floating around that uses the indexer to save copies of the properties in a dictionary then writes them back using the indexer in order to capture parameters without knowing their names and types ahead of time, at minimum the indexer should allow one to set Encrypt to an instance of SqlConnectionEncryptionOption. It'd be nice if it supported a bool setter too.
Otherwise in SSMS 20 we'll have to modify the designer code to special case this option to convert the stored value to a string.
The text was updated successfully, but these errors were encountered:
This code:
Prints the following:
Given that there's client code floating around that uses the indexer to save copies of the properties in a dictionary then writes them back using the indexer in order to capture parameters without knowing their names and types ahead of time, at minimum the indexer should allow one to set
Encrypt
to an instance ofSqlConnectionEncryptionOption
. It'd be nice if it supported a bool setter too.Otherwise in SSMS 20 we'll have to modify the designer code to special case this option to convert the stored value to a string.
The text was updated successfully, but these errors were encountered: