T
Tinus
Hello all,
I've been searching for an answer for a day now (Google) and can't find what
I'm doing wrong :-(
The problem is as follows. I'm trying to read a blob from a mysql table.
However I get the following error:
'Source array was not long enough. Check scrIndex and lenght, and the
array's lower bounds.'
Image photo = null;
while (reader.Read())
{
long len = reader.GetBytes(1, 0, null, 0, 0);
Byte[] buffer = new Byte[len];
reader.GetBytes(1, 0, buffer, 0, (int)len);
photo = Image.FromStream(new MemoryStream(buffer));
}
The image is correctly stored in the MySql table as a blob because I can get
the image back using a DataTable and display it in a pictureBox. But I want
to use the reader function.
Hopefully someone here can help me solve the problem which lies in the above
code!? The mentioned error is generated on the code: reader.GetBytes(1, 0,
buffer, 0, (int)len);
Thanks in advance!
Regards,
Tinus
I've been searching for an answer for a day now (Google) and can't find what
I'm doing wrong :-(
The problem is as follows. I'm trying to read a blob from a mysql table.
However I get the following error:
'Source array was not long enough. Check scrIndex and lenght, and the
array's lower bounds.'
Image photo = null;
while (reader.Read())
{
long len = reader.GetBytes(1, 0, null, 0, 0);
Byte[] buffer = new Byte[len];
reader.GetBytes(1, 0, buffer, 0, (int)len);
photo = Image.FromStream(new MemoryStream(buffer));
}
The image is correctly stored in the MySql table as a blob because I can get
the image back using a DataTable and display it in a pictureBox. But I want
to use the reader function.
Hopefully someone here can help me solve the problem which lies in the above
code!? The mentioned error is generated on the code: reader.GetBytes(1, 0,
buffer, 0, (int)len);
Thanks in advance!
Regards,
Tinus