public static byte[] convertBlobToBufferData(String column,MySqlDataReader rdr)
{
int bufferSize = 1024; // Number of bytes to read at a time
byte[] ImageData = new byte[bufferSize];
long nBytesReturned, startIndex = 0;
int ordinal = rdr.GetOrdinal(column);
string image = rdr.IsDBNull(ordinal) ? null : rdr.GetString(column);
if (image != null)
{
startIndex = 0;
nBytesReturned = rdr.GetBytes(
ordinal, // Column index of BLOB column
startIndex, // Start position of the byte to read
ImageData, // Byte array to recieve BLOB data
0, // Start index of the array
bufferSize // Size of buffer
);
while (nBytesReturned == bufferSize)
{
startIndex += bufferSize;
nBytesReturned = rdr.GetBytes(ordinal, startIndex, ImageData, 0, bufferSize); // Number of bytes returned is assigned to nBytesReturned
}
return ImageData;
}
else
{
return null;
}
}