Hi there,
I am trying to retrieve and view in a picturebox, an image I saved in mysql database as an image data type. When I open my database I see in the image column "<Binary data>"
Now I am trying to select data and along with it this image, below is the code i thought would work.
private void button2_Click(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection("Data Source=KATOTO-PC;Initial Catalog =AssetRegister;User ID=sa;Password=Kyozi");
string sql = ("select serialnumber,supplier,assetimage from AssetInformation where serialnumber like '" + textBox1.Text + "'");
SqlCommand cmd = new SqlCommand(sql, cn);
cn.Open();
SqlDataReader sdr = cmd.ExecuteReader();
sdr.Read(); // read first row
textBox2.Text = sdr[1].ToString(); // read first column
pictureBox2.Image = sdr[2].ToString();
}
I can't even run because of a number of errors.
Any help will be kindly appreciated.
Best regards.