Click here to Skip to main content
15,917,565 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am creating windows application using c# 2010, here i am upload a image for products details but below error is came. how to solve this error any one give me ideas.

C#
Unable to cast object of type 'System.Drawing.Bitmap' to type 'System.IConvertible'.

 cmd2.Parameters.AddWithValue("@imgmodel", Convert.ToByte(pictureBox1.Image));


What I have tried:

C#
Image updating error on c# 2010 windows application 
Posted
Updated 23-Dec-16 14:19pm

1 solution

You can't "convert" a Bitmap object to anything.

You have to create a MemoryStream object and "save" the bitmap to it. You can then get the array of bytes from the MemoryStream.

But, you've already been told this, here[^]. Try not to ignore the answers you're given next time.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900