conn.Open(); using(SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess)) { reader.Read(); // Get size of image data – pass null as the byte array parameter long bytesize = reader.GetBytes(0, 0, null, 0, 0); // Allocate byte array to hold image data byte[] imageData = new byte[bytesize]; long bytesread = 0; int curpos = 0; while (bytesread < bytesize) { // chunkSize is an arbitrary application defined value bytesread += reader.GetBytes(0, curpos, imageData, curpos, chunkSize); curpos += chunkSize; }Stream s = new MemoryStream(); s.Write(imageData,0,bytesize); Bitmap MyImage = new Bitmap(s); pictureBox1.Image = (Image) MyImage ;}
using(SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess))
{
reader.Read();
// Get size of image data – pass null as the byte array parameter
long bytesize = reader.GetBytes(0, 0, null, 0, 0);
// Allocate byte array to hold image data
byte[] imageData = new byte[bytesize];
long bytesread = 0;
int curpos = 0;
while (bytesread < bytesize)
{
// chunkSize is an arbitrary application defined value
bytesread += reader.GetBytes(0, curpos, imageData, curpos, chunkSize);
curpos += chunkSize;
}Stream s = new MemoryStream();
s.Write(imageData,0,bytesize);
Bitmap MyImage = new Bitmap(s);
pictureBox1.Image = (Image) MyImage ;}