I get an error on this line

Code : Sélectionner tout - Visualiser dans une fenêtre à part
Image returnImage = Image.FromStream(ms);
The error is:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
Le paramètre n'est pas valide (Invalid Parameter)
Can someone help me with this one?

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
namespace WindowsFormsApplication1
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
            SqlConnection cnx = new SqlConnection(WindowsFormsApplication1.Properties.Settings.Default.testConnectionString);
            cnx.Open();
            string query = "select * from [dbo].[Table]";
            SqlCommand cmd = new SqlCommand(query, cnx);
            SqlDataReader reader = cmd.ExecuteReader();
 
            while (reader.Read())
            {
 
                if (reader[1] != System.DBNull.Value)
                {
                    Byte[] image = (Byte[])reader[1];
                    pictureBox1.Image = byteArrayToImage(image);
                }
            }
        }
 
        public Image byteArrayToImage(byte[] byteArrayIn)
        {
            using (MemoryStream ms = new MemoryStream(byteArrayIn))
            {
                Image returnImage = Image.FromStream(ms);
                return returnImage;
            }
        }
    }
}