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
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Posted Oct 13, 2006, 4:38 AM
Posted Oct 13, 2006, 4:38 AM
iza zainPosted Oct 11, 2006, 4:49 AM
// 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 arrayFileStream 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 boxpicFlashcard.Image =
new Bitmap("tmp.gif");sourav SauPosted Oct 11, 2006, 1:19 AM
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