C# SQL Server程序集和SQLBinary数据类型
我有一个c程序集,它接受一个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
[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。。。嗯!: