Getting binary data using SqlDataReader
You should be able to get it via: (byte[])reader["Data"]
.
Also note that the image
data type is deprecated, and will be removed in a future version of SQL Server; use varbinary(max)
instead.
Yes, you can use SqlDataReader.GetBytes
. You probably want to pass in null
for the buffer in the first call, to find out how much data there is, and then call it again with an appropriately sized buffer.
You may just be able to use the indexer and cast the result to a byte array - I'm not sure. Worth a try :)