We have some fields of type nchar to support Unicode characters.
Always encrypt is enabled for the table.
Inserting data works fine but when I try to retrieve data, the below error is thrown from Recordset Open function:
>The data types nchar(128) encrypted with (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'ColumnEncryptionKey1', column_encryption_key_database_name = 'DATABASE') and varchar(128) encrypted with (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'ColumnEncryptionKey1', column_encryption_key_database_name Statement(s) could not be prepared.
I am unable to understand why varchar is mentioned in the error when the table data type is nchar.
Can someone help to decipher what the error is trying to state?
SQL Server version:
SQL Server 2019 Express Edition
Table generation script:
USE [DATABASE]
CREATE TABLE [dbo].[TABLE_1](
[secondName] [nchar](128) NULL,
[firstName] [nchar](128) NULL,
[Id] [nchar](128) NOT NULL,
[height] [int] NULL,
PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
The query that is passed to Recordset open function is a select query with Id as search key.
select * from TABLE_1 where Id=?
The previous error was obtained when I did remote debugging. On a similar environment when done locally, the below error is obtianed:
> The data types nchar(128) encrypted with (encryption_type =
> 'DETERMINISTIC', encryption_algorithm_name =
> 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name =
> 'ColumnEncryptionKey1', column_encryption_key_database_name =
> 'DATABASE') and varchar(128) encrypted with (encryption_type =
> 'DETERMINISTIC', encryption_algorithm_name =
> 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name =
> 'ColumnEncryptionKey1', column_encryption_key_database_name =
> 'DATABASE') collation Statement(s) could not be prepared.
Setting sting parameter is done in DoFieldExchange() function of Recordset class as below:
RFX_Text(pFX, ParameterName, *pstring, Length);
where pstring is of type CString*
Asked by Amal Jesudas
(69 rep)
Feb 12, 2023, 06:02 AM
Last activity: Feb 13, 2023, 01:19 PM
Last activity: Feb 13, 2023, 01:19 PM