OleDbCommand and = new OleDbCommand();
c.Open();
and.Connection = c;
and.CommandText = "SELECT * FROM MaleShoes WHERE IDhere=ID ";
OleDbDataReader read = and.ExecuteReader();
while (read.Read())
{
label6.Text = (read[1].ToString());
textBox1.Text = (read[2].ToString());
pictureBox1.Image = (read[3].ToString());
}
c.Close();
I got this error:
Error 1 Cannot implicitly convert type 'string' to 'System.Drawing.Image'
How should I fix it?
My pictures are in my database on the third column.
If you your database column contains the path to the image file, you should write:
pictureBox1.Image = Image.FromFile((string)read[3]);
If it is the image data (binary), you should write:
var bytes = (byte[])read[3];
using(MemoryStream ms = new MemoryStream(bytes))
{
pictureBox1.Image = Image.FromStream(ms);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With