Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# SQL Server程序集和SQLBinary数据类型_C#_Sql Server_Assemblies_Types_Varbinary - Fatal编程技术网

C# SQL Server程序集和SQLBinary数据类型

C# SQL Server程序集和SQLBinary数据类型,c#,sql-server,assemblies,types,varbinary,C#,Sql Server,Assemblies,Types,Varbinary,我有一个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 runQuer

我有一个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;
我将SqlBinaryargValue作为列包含在select语句中,以便进行简单调试。看起来好像这个SqlBinary值没有正确地放入查询中

argValue的使用方式如下:

QueryString += "SELECT decryptbykey(@argValue);";

返回的内容看起来像是SqlBinaryargValue的截断版本

回答我自己的问题:

我必须将decryptbykey的结果强制转换为varchar。。。嗯!: