1

I have image into sql datatable and read it and display successfully into win form. But I can't insert that picture (which I get from database) from datatable in vb dataset. Data type for image in datatable is byte()... I think problem is in this line:

adoCommandInsertElement.Parameters(4).Value = dataset.UgovorUgovorElement_Select.Rows(i).Item(5)

adoCommandInsertElement.Parameters(4).Value is image and Me.dataset.UgovorUgovorElement_Select.Rows(i).Item(5) is byte()

The error is: failed to convert parameter value from a byte[] to a decimal. system.invalidcastexception , object must implement IConvertible

Eli Gassert
  • 9,745
  • 3
  • 30
  • 39
Naum
  • 125
  • 1
  • 3
  • 12
  • I see that this is the opposite of what the thread is doing. You need to convert a Byte array to an Image. Can you change the ado command to a Byte array instead? If not, then hopefully the thread I referenced above will put you on the right path. Also see http://www.codeproject.com/Articles/15460/C-Image-to-Byte-Array-and-Byte-Array-to-Image-Conv for reference – Eli Gassert Mar 12 '13 at 10:15
  • I want to reformulate my answer: I have datatable in vb with byte() column which has image from sql. I can show this byte() in picturebox in my form, buy I want to insert that image from datatable into new row in sql? – Naum Mar 12 '13 at 12:46
  • If your question is changing, close this question and open a new one, or edit this one to properly reflect your question. I don't understand the changes you are making based on your comment, sorry. You need to give as much information as possible (and even more if you think that your English is the cause of confusion). So which is it: you want to show it in a picturebox; or you want to use an ado command to insert a byte array into the database? Try to keep to one question per post. – Eli Gassert Mar 12 '13 at 13:04
  • I want to use ado command to insert a byte array into database... – Naum Mar 12 '13 at 13:28

0 Answers0