2
Reply

binding blob with picturebox

Florentin Izvoranu

Florentin Izvoranu

May 13 2010 6:25 AM
5.8k
Hi,
I'm a beginer in c sharp and I can't pass over a problem. I would like to bind a blob field (mysql) with a picturebox in c sharp;

here is the code:


  1. string query = "Select name,director,picture from Movies where Movies.name='" + search + "'";
  2.                 //create command and assign the query and connection from the constructor
  3.                 MySqlCommand cmd = new MySqlCommand(query, connection);
  4.  
  5.                 //Execute command
  6.                 MySqlDataReader dr;
  7.  
  8.                 dr = cmd.ExecuteReader();
  9.                 if (dr.HasRows)
  10.                 {
  11.                     while (dr.Read())
  12.                     {
  13.                         txtname.Text = (dr["Name"] + "");
  14.                         txtdirector.Text = (dr["Director"] + "");
  15.                         txtactors.Text = (dr["Actors"] + " "");
  16.                     }
  17.                 }
  18.                 else
  19.                     MessageBox.Show("The movie is unavailable");

What shall I do to extract the picture form database and put it in a picturebox
like I put the other fields in textbox ?  If anybody know, I would like an exact answer not a link,
 because I use mysql not sql and because I already done a lot of searching on this topic bu
 without succes.

thank you in advance

Answers (2)