I am getting a SqlException
:
Operand type clash: varchar is incompatible with varchar(50) encrypted with (encryption_type = \'DETERMINI
If someone is still looking for an answer on this, what worked for me is that you need to use DbType.AnsiStringFixedLength
data type in the SqlParameter data type, for the encrypted columns.
Refer this article for more information
Anyone who still face this issue and none of the above checks didn't help, make sure the parameter names exactly match (case sensitively) both in the procedure and the code.
There are 2 things you can try,
Ensure that Column encryption setting is enabled in your connection string. This can be done using a SqlConnectionStringBuilder
object and setting SqlConnectionStringBuilder.ColumnEncryptionSetting
to Enabled
as follows
strbldr.ColumnEncryptionSetting = SqlConnectionColumnEncryptionSetting.Enabled;
If your stored procedure was created before you encrypted your column, you will need to refresh metadata for your stored procedure as follows
Use [Database]
GO
--Do this for all stored procedures
EXEC sys.sp_refresh_parameter_encryption @name = '[dbo].[Clients_Insert]'