0

I am using this syntax where the dr.getValue(6) is the blob image from mysql.

public void LoadRecords()
{
    metroGrid1.Rows.Clear();
    cm = new MySqlCommand("Select * from tblaccnt", cn);

    dr = cm.ExecuteReader();
    while (dr.Read())
    {
        metroGrid1.Rows.Add(dr.GetValue(0), dr.GetValue(1), dr.GetValue(2), dr.GetValue(3), dr.GetValue(4), dr.GetValue(5), dr.GetValue(6));

    }

    dr.Close();
}

But I always end up with Parameter is not valid Exception. Thanks in advance for the help

1 Answer 1

0

You have to set byte array for your image

  (byte[])reader["ImageData"] 

And then convert to Image

 MemoryStream ms = new MemoryStream((byte[])reader["ImageData"]);
 Image returnImage = Image.FromStream(ms);
Sign up to request clarification or add additional context in comments.

2 Comments

I still got Parameter not valid at the Image.FromStream(ms);
try this approuch for converting your byte array stackoverflow.com/a/17668083/2470530

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.