hye, i tried the example to read and save image in sql server, but i got "specified cast is not valid"
can someone please help me to solve this? where to put the temporary image? i put it in debug folder but it didnt work
Read and save image in sql server
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
sourav Sau4 pointsPosted Oct 10, 2006, 9:19 PM EDT
please tell one thing that do u want to save the image (in binary format) or u just want to save images in a folder in urproject and save the url in the database and retrive the image through that url.
If want the 1st case,then take data type image. and then save that image.
hope this will help you
iza zain3 pointsPosted Oct 11, 2006, 12:49 AM EDT
// Get the picture from the DataRow and assign it to // a byte array byte[] MyPicture = null; MyPicture = (byte[])dsFlashcard.Tables[0].Rows[0]["Picture"]; int ArraySize = new int(); ArraySize = MyPicture.GetUpperBound(0); // After retrieving the byte array, I get the number of elements of // the array for use in writing the array FileStream fsFlashcard = new FileStream("tmp.gif", FileMode.OpenOrCreate, FileAccess.Write); // Create a filestream for writing the byte array to a gif // file (my picture format - .gif) fsFlashcard.Write(MyPicture,0,ArraySize+1); fsFlashcard.Close(); // Assign the temporary gif file to the picture box picFlashcard.Image = new Bitmap("tmp.gif");Former memberPosted Oct 13, 2006, 12:38 AM EDT
Former memberPosted Oct 13, 2006, 12:38 AM EDT