I’m retrieving image from DB using Stream. Need someone to help me to convert to byte.
My code.
//connection.Open();
string sql = "SELECT Photo FROM ImageTable WHERE TagId = @ID";
SqlCommand cmd = new SqlCommand(sql, connection);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@ID", tagid);
connection.Open();
object img = cmd.ExecuteScalar();
try
{
return new MemoryStream((byte[])img);
}
catch
{
return null;
}
before I return I need to change to byte. Someone please help.
I don’t think this is what you really want, but since the question is how to convert
MemoryStreamtobyte[]: