SQL Server 程序集和 SQLBinary 数据类型
我有 c# 程序集,它接受 SQLBinary 变量来解密...
[SqlProcedure(Name="Decrypt")]
public static SqlInt32 Decrypt(SqlBinary toDecrypt)
{
return runQuery(toDecrypt);
}
// decrypt or encrypt is determined based on the datatype of argValue
private static SqlInt32 runQuery(object argValue)
{
// create connection and command
command.Parameters.Add("@argValue", SqlDbType.VarBinary, 1024).Value = (SqlBinary)argValue;
我将 (SqlBinary)argValue 作为列包含在 select 语句中以进行简单调试。 看起来好像这个 SqlBinary 值没有正确放入查询中。
argValue 的使用方式如下:
QueryString += "SELECT decryptbykey(@argValue);";
返回的内容看起来像是 (SqlBinary)argValue 的截断版本
I have a c# assembly which takes in a SQLBinary variable to decrypt...
[SqlProcedure(Name="Decrypt")]
public static SqlInt32 Decrypt(SqlBinary toDecrypt)
{
return runQuery(toDecrypt);
}
// decrypt or encrypt is determined based on the datatype of argValue
private static SqlInt32 runQuery(object argValue)
{
// create connection and command
command.Parameters.Add("@argValue", SqlDbType.VarBinary, 1024).Value = (SqlBinary)argValue;
I include the (SqlBinary)argValue as a column in the select statement for simple debugging. It doesnt appear as if this SqlBinary value is properly being placed into the query.
argValue is being used like so:
QueryString += "SELECT decryptbykey(@argValue);";
Whats being returned looks like a truncated version of (SqlBinary)argValue
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
回答我自己的问题:
我必须将decryptbykey 的结果转换为varchar ... 呃! :)
Answer to my own question:
I had to cast the result of decryptbykey to a varchar ... duh! :)