not properly updating image from DataGridView in winform application

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jaseem0712
    New Member
    • Jun 2013
    • 7

    not properly updating image from DataGridView in winform application

    I have a DataGridView, which has a image column:
    Update Button_Click:
    Code:
     Dim dtimage As Image
        {
            using (MemoryStream ms = new MemoryStream(rv.Row.Field<byte[]>("empimage"))) {
                dtimage = new Bitmap(ms);
            }
        }
    Update query:
    Code:
    adapter.UpdateCommand == new SqlCommand("update DepartmentMaster_tbl set dtName = @dtName,dtPhone = @dtPhone,dtEmail = @dtEmail,empimage=@dtimage  where dtId=@dtid", con.connect)
    Then I'am converting the image, so that I can save it to my SQL-Server
    Code:
    MemoryStream md = new MemoryStream();
    dtimage.Save(md, System.Drawing.Imaging.ImageFormat.Gif);
    byte[] bmpBytes = md.GetBuffer();
    adapter.UpdateCommand.Parameters.AddWithValue("@dtimage", bmpBytes);
    adapter.UpdateCommand.ExecuteNonQuery();
    I'm not getting any error after executing this. The image is saved as some black color:[IMG][/IMG]
Working...