带有 Always Encrypted 列的 SqlBulkCopy
SqlBulkCopy with Always Encrypted column
我正在通过 .Net 代码导入 CSV 并获取数据 table 中的数据,并尝试使用 SqlBulkCopy 批量插入,但我收到证书错误。当我尝试执行其他操作时,只有在执行 SqlBulkCopy 时才会出现证书错误。这是错误描述
Failed to decrypt a column encryption key using key store provider:
'MSSQL_CERTIFICATE_STORE'. The last 10 bytes of the encrypted column
encryption key are: '7F-1D-20-E1-43-0B-B5-92-66-78'. Certificate with
thumbprint 'XXXXXXXXXXXXXXXXXXXXXXXXXX' not found in certificate store
'My' in certificate location 'CurrentUser'. Verify the certificate
path in the column master key definition in the database is correct,
and the certificate has been imported correctly into the certificate
location/store. Parameter name: masterKeyPath
我在本地机器上导入了证书。下面是代码
我在 dt datatable 对象中有数据。从 worksheet.Cells.ExportDataTableAsString.
返回
Dim copy As New SqlBulkCopy(ConnString, SqlBulkCopyOptions.KeepIdentity Or SqlBulkCopyOptions.AllowEncryptedValueModifications)
copy.DestinationTableName = "Customer"
copy.ColumnMappings.Add("CustID", "CustID")
copy.ColumnMappings.Add("SSN", "SSN")
copy.WriteToServer(dt)
如果我们按照上面的方法进行,我们需要执行第 2 轮操作以插入 data.i 具有 Worksheet ExportDataTableAsString 返回的数据table 对象。当我直接将数据table 用于SQLbulkcopy 时,出现证书丢失错误。
谁能帮我解决这个问题并提出更好的方法。
右击证书-所有任务-管理私钥-添加用户
IIS AppPool[DefaultAppPool] 对我有用。
我正在通过 .Net 代码导入 CSV 并获取数据 table 中的数据,并尝试使用 SqlBulkCopy 批量插入,但我收到证书错误。当我尝试执行其他操作时,只有在执行 SqlBulkCopy 时才会出现证书错误。这是错误描述
Failed to decrypt a column encryption key using key store provider: 'MSSQL_CERTIFICATE_STORE'. The last 10 bytes of the encrypted column encryption key are: '7F-1D-20-E1-43-0B-B5-92-66-78'. Certificate with thumbprint 'XXXXXXXXXXXXXXXXXXXXXXXXXX' not found in certificate store 'My' in certificate location 'CurrentUser'. Verify the certificate path in the column master key definition in the database is correct, and the certificate has been imported correctly into the certificate location/store. Parameter name: masterKeyPath
我在本地机器上导入了证书。下面是代码 我在 dt datatable 对象中有数据。从 worksheet.Cells.ExportDataTableAsString.
返回Dim copy As New SqlBulkCopy(ConnString, SqlBulkCopyOptions.KeepIdentity Or SqlBulkCopyOptions.AllowEncryptedValueModifications)
copy.DestinationTableName = "Customer"
copy.ColumnMappings.Add("CustID", "CustID")
copy.ColumnMappings.Add("SSN", "SSN")
copy.WriteToServer(dt)
如果我们按照上面的方法进行,我们需要执行第 2 轮操作以插入 data.i 具有 Worksheet ExportDataTableAsString 返回的数据table 对象。当我直接将数据table 用于SQLbulkcopy 时,出现证书丢失错误。
谁能帮我解决这个问题并提出更好的方法。
右击证书-所有任务-管理私钥-添加用户
IIS AppPool[DefaultAppPool] 对我有用。