DataTable with a byte[] field as parameter to a stored procedure

末鹿安然 提交于 2019-11-30 19:16:22

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!