I\'ve been reusing this method of using a DataTable as a parameter to a stored procedure and it\'s been working great. This is the simplified working code:
The representation for a binary string in .NET is the SqlBinary structure.
You want to add your column like this:
dt.Columns.Add("BinaryMessage", typeof(SqlBinary));
The SqlBinary
class has an explicit conversion to a byte array and an implicit conversion from a byte array, so the value from a byte array to the column is a simple matter of assignment, while getting a byte array from the column requires an explicit cast.