I have problem about insert picture to my SQL database
Omid Nosratian
yeh, of course the picture which u take it should be binary type
or another way is to link the that picture in ur datatable
mean save the picture in ur pc and link that location it's easiest way but not proffessional
To Insert the picture first u need to take the picture box and then convert the picture into the memory stream and after that store it into byte[] array and then store into the dataaseMemorStream ms=new MemoryStream();pictureBox1.image.Save(ms,ImageType.JPG);byte[] data=new byte[ms.Length);int position=0;ms.Read(data,0,Convert.ToInt32(ms.Lenght));Then Add the Parameter to the data base asCmd.Parameters.addWithKey("@Photo",data);
it should be binary type
when i try to insert a picture to the database's table ,occured an exception, the data type of the Picture's field in table of the database is Image .
the exception occured on this code:
newRow["Picture"] = pictureBox1.Image;
and the exception error is: