Writing large chunks of binary data to MySQL with ODBC

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I'm having a lot of trouble writing large chunks of binary data (tests
are in the range of 16-512K, but we need support for large longblobs) to
MySQL using ODBC.  Database is local on a W2K system, but I have to
support all modern Windows systems, and a variety of ODBC configurations.
(I'll be testing against multiple ODBC databases soon - but development
is against MySQL)

I've been able to adapt some example code that executes a statement
(SQLExecute) and uses SQLBindParameter to mark the longblob field as
SQL_DATA_AT_EXEC. That works.

However I really need to use a result set (opened for update), and to
add new rows using SQLBulkOperation( hStmt, SQL_ADD)
This works for the normally bound fields, but fails if I bind a variable
using something like:

m_ValueSize_Indicator = SQL_LEN_DATA_AT_EXEC(m_nSize);
rc = SQLBindCol( hStmt, m_nColNumber, m_CType, (unsigned
char*)(m_pNameData), m_sName.length(), &m_ValueSize_Indicator );

where m_pNameData (and m_sName) both store the identifying name for the
"Need More Data".  m_nColNumber is the column number (1). m_CType is the
C datatype constant.

The error I get is ODBC Error HY000, Native Error 4001
"[MySQL][ODBC 3.51 Driver][mysqld-4.1.10a-nt]General driver defined error"

Has anyone seen anything like this before?  Any suggested solutions?

Does anyone have any sample code for using SQLBindCol and
SQLBulkOperation to write a new row of data to a result set that
includes a large binary field?

Thanks in advance,


Richard Marsden
Winwaed Software Technology, http://www.winwaed.com
http://www.mapping-tools.com for MapPoint tools and add-ins

Site Timeline