简体   繁体   中英

Error inserting into database with Node.JS and SQL Server Always Encrypted

I using a SQL Server database with the Always Encrypted features. When I try to insert a row, it fails and throws an error

let request = new Request(`INSERT INTO [dbo].[table_name] ([Name])
                           VALUES ('test')`,
                function (err, rowCount, rows) {
                    if (err) {
                        console.log('errr--', err);
                    } else {
                        console.log(' row(s) ', rows);
                    }
                });

Error:

RequestError: Operand type clash: varchar is incompatible with varchar(8000) encrypted with (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEK_Auto1', column_encryption_key_database_name = 'DrugstoreDB') collation_name = 'SQL_Latin1_General_CP1_CI_AS'_```

Where is the problem?

AlwaysEncrypted is client-side encryption, so must be supported by your client driver. AFAIK the current list of client libraries that have implemented AlwaysEncrypted is:

-SqlClient for .NET Framework (but not .NET Core/.NET Standard)

-Microsoft ODBC Driver for SQL Server for Windows

-Microsoft ODBC Driver for SQL Server for Linux

-Microsoft JDBC Driver for SQL Server

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM