Skip to content

Error when using Always Encrypted and Update record #16

Description

@WillyBilly90

I got this error when updating a record when updating a record with columns which are encrypted.

Operand type clash: varchar(14) encrypted with (encryption_type = 'RANDOMIZED', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEK_Auto1', column_encryption_key_database_name = 'WCCASHDESK') collation_name = 'Latin1_General_CI_AS' is incompatible with nvarchar(50) encrypted with (encryption_type = 'RANDOMIZED', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEK_Auto1', column_encryption_key_database_name = 'WCCASHDESK')

The used sql command is this:

string sql = "UPDATE dbo.Klant SET Voornaam=@Voornaam, Tussenvoegsel=@Tussenvoegsel, Achternaam=@Achternaam, Bedrijfsnaam=@Bedrijfsnaam ,Straat=@Straat ,Huisnummer=@Huisnummer, Postcode=@Postcode, Plaats=@Plaats, Telefoon1=@Telefoon1, Telefoon2=@Telefoon2, Email=@Email WHERE KlantId=@KlantId";

                AceQLCommand command = new AceQLCommand(sql, conn);
                command.Parameters.AddWithValue("@KlantId", klant.KlantId);
                command.Parameters.AddWithValue("@Voornaam", klant.Voornaam);
                command.Parameters.AddWithValue("@Tussenvoegsel", klant.Tussenvoegsel);
                command.Parameters.AddWithValue("@Achternaam", klant.Achternaam);
                command.Parameters.AddWithValue("@Bedrijfsnaam", klant.Bedrijfsnaam);
                command.Parameters.AddWithValue("@Straat", klant.Straat);
                command.Parameters.AddWithValue("@Huisnummer", klant.Huisnummer);
                command.Parameters.AddWithValue("@Postcode", klant.Postcode);
                command.Parameters.AddWithValue("@Plaats", klant.Plaats);
                command.Parameters.AddWithValue("@Telefoon1", klant.Telefoon1);
                command.Parameters.AddWithValue("@Telefoon2", klant.Telefoon2);
                command.Parameters.AddWithValue("@Email", klant.Email);

                rows = await command.ExecuteNonQueryAsync();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions