Operand type clash: varchar is incompatible with varchar(50) trying to insert in encrypted database

血红的双手。 提交于 2019-11-29 08:16:14

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]'

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!