Invalid parameter, MemoryStream

2

Good afternoon guys, I'm developing a small project in that needs to present an image along with a recipe and is the first time I work with image in database, I already inserted the image in the database. In the project ( C# ) when I pass the parameter of type MemoryStream of error:

  

Invalid parameter.

var receitaP1 = cmd.ExecuteReader();

while (receitaP1.Read())
{
    receita.CodReceita = Convert.ToInt16(receitaP1["codReceita"].ToString());
    receita.NomeReceita = receitaP1["nomeReceita"].ToString();
    receita.ModoPreparo = receitaP1["modoDePreparo"].ToString();
    receita.Tipo = receitaP1["nomeTipo"].ToString();

    byte[] imagem = (byte[]) receitaP1["imagem"];
    MemoryStream memoria = new MemoryStream(imagem);

    Image image = Image.FromStream(memoria); //"Memoria" >>> Erro: parametro invalido!

    receita.Imagem = image;
}

Look, it's already position 0

Insertindatabase:

    
asked by anonymous 30.04.2018 / 20:27

0 answers