MySQL & BLOB field retrieving



Dear Group,

I'm connecting in C# with remote (BSD) MySQL server with ODBC Driver,
and I'm trying to find the best sollution in such problem:

As I've read on MySQL manual, they have suggested table design
including the BLOB-Fieldtype size in UInt64, where they've stored,
while inserting, the size of inserted BLOB data. But in the matter of
fact, I'm interested if it's necessary to include in table this integer
field? Is there any way to get size of inserted blob data? In matter of
fact, just before fetching data, I may create byte[] array with size
equal maximum capacity of medium/tiny/*/blob fields, but it's kind of
wasting memory, isn't it?

Thanks a lot for all answers & proposals and time wasted on my problem.

Best regards,
Przemek M. Zawada

D. Yates


Here is a way of reading blob without knowing its size to start with:

However, in our Interbase database, we store the size in another field and
then use it with the OdbcDataReader's GetBytes method to read it all the
data at once.

I've not used MySQL; however, I just recently read that the version 5.0 of
the database comes with .NET database drivers. I took a look at the
MySqlDataReader methods at:
and I don't see a method other than the GetBytes method for retrieving
binary information from a database, so you are probably going to have use
the same sort of retrieval method as the OdbcDataReader class offers, which
is kind of sad. Oh well, I would assume that the MySql native components
can retrieve data from the MySQL database faster than the Odbc components
that come with .NET, so you may want to use them or at least test my theory.



Indeed! Thank you for hints! GetBytes() works perfectly!

Best regards,
Przemek M. Zawada

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question