Keep in touch

you can keep in touch with my all blogs and sites by install this Toolbar...
http://rworldtoolbar.ourtoolbar.com/

Friday, September 26, 2008

code to store and retrieve image from sql server

Image tmpImg = pictureBox1.Image;
System.IO.MemoryStream memBuffer = new System.IO.MemoryStream();
tmpImg.Save(memBuffer, System.Drawing.Imaging.ImageFormat.Bmp);
byte[] output = new byte[memBuffer.Length];
memBuffer.Read(output, 0, (int)memBuffer.Length);
// Write to SQL here

// Read from SQL here
memBuffer.Write(output, 0, output.Length);
tmpImg = Image.FromStream(memBuffer);
pictureBox1.Image = tmpImg;

No comments: