leathu raj

leathu raj

  • NA
  • 62
  • 78k

Retrive images from local database(.sdf) to picturebox in c#

Jul 1 2014 6:45 AM
Hi,
  Small help.... I need to get images from my local database(.sdf). I saved image into  local database but i cant get it to my picturebox in my application. My codings are


                string sql = "Select gift_img from gift_entry where gift_points = '" + comboBox_id.Text + "'";
                if (conn.State != ConnectionState.Open)
                    conn.Open();
                SqlCeCommand command = new SqlCeCommand(sql, conn);
                command.CommandType = CommandType.Text;
                command.ExecuteNonQuery();

                SqlCeDataReader reader = command.ExecuteReader();
               
                reader.Read();
                if (reader.HasRows)
                {
                    byte[] img = (byte[])(reader[0]);
                    if (img == null)
                        pictureBox1.Image = null;
                    else
                    {
                        MemoryStream ms = new MemoryStream(img);
                        pictureBox1.Image = Image.FromStream(ms);


                    }
                }
this same coding was worked in sql database.. but this is not worked in local database...

Please Help me.....