How to save and retrive image from/to picture box

Oct 1 2011 4:14 AM

i have selected the image using openfiledialog and loaded it to the picturebox in c# desktop app.

now i want to save the image, while saving the image it raises the exception that [] , these brackets are invalid parameters.

my code is.

MemoryStream stream=new MemoryStream();

here pic is of byte[] type. which is class level variable.

then i store pic in insert query like this.

 string str = "insert into branches (branchcode,branchname,address,landlinecell,picture,description) values(" + branchcode + ",'" + branchname + "','" + address + "','" + landline + "'," + @pic+ ",'" + description + "')";

and then send the query to my save method to do the insertion operation.

what is the problem??

Answers (8)