使用Node.JS和SQL Server始终加密插入数据库时​​出错

时间:2018-05-26 17:14:50

标签: sql-server node.js azure encryption always-encrypted

我使用带有Always Encrypted功能的SQL Server数据库。当我尝试插入一行时,它会失败并抛出错误

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);
                    }
                });

错误:

  

RequestError:操作数类型冲突:varchar与使用加密的varchar(8000)不兼容(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')collat​​ion_name ='SQL_Latin1_General_CP1_CI_AS'_ ```

问题出在哪里?

1 个答案:

答案 0 :(得分:0)

AlwaysEncrypted是客户端加密,因此必须得到客户端驱动程序的支持。 AFAIK当前已实施AlwaysEncrypted的客户端库列表是:

-SqlClient for .NET Framework(但不是.NET Core / .NET Standard)

- 适用于Windows的SQL Server的Microsoft ODBC驱动程序

- 适用于Linux的SQL Server的Microsoft ODBC驱动程序

- 用于SQL Server的Microsoft JDBC驱动程序