我在插入查询中ENCRYPTBYKEY
使用参数化查询时遇到问题。SQL
它只加密和解密第一个字符。
这是我的代码:
sqlParameters[0, 0] = "@DatabaseVersion";
sqlParameters[0, 1] = this.TextBox1.Text.Trim();
queryString = "OPEN SYMMETRIC KEY Sym_password " +
"DECRYPTION BY CERTIFICATE Cert_Password WITH PASSWORD = 'myPassword'" +
"Insert Into zz_database_version " +
"( " +
" DatabaseVersion " +
") " +
"Values " +
"( " +
"ENCRYPTBYKEY(KEY_GUID('Sym_password'), @DatabaseVersion) " +
") " +
"CLOSE SYMMETRIC KEY Sym_password";