Bug #3112 AddNew MFC function doesn't work with "blob" fields?
Submitted: 9 Mar 2004 2:18 Modified: 29 May 2013 12:57
Reporter: Arto Hakola Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S1 (Critical)
Version:3.51.06 OS:Microsoft Windows (XP)
Assigned to: CPU Architecture:Any

[9 Mar 2004 2:18] Arto Hakola
Description:
I have Visual C++ .NET 2002/2003 environments and I'm trying to store BLOB fields to the mysql 4.0.18 database. API I'm using is MFC ODBC classes(CRecordSet).
Result is that I cannot do anything through the MFC API? Even adding recordset classes through the .NET class wizard doesn't work with the current MyODBC driver? Older driver worked better?

How to repeat:
Here's a code snippet of how I try to store files to the database table:

CdbImages       dbImages(&theApp.m_DB);
CFileDialog     fd(TRUE,NULL,NULL,0,szFilter,this);

try
    {
        dbImages.Open();
        dbImages.AddNew();

        CFile		fileImage;
        CFileStatus	fileStatus;

        fileImage.Open(fd.GetPathName(), CFile::modeRead);
        fileImage.GetStatus(fileStatus);

        dbImages.m_BLOBName = fileImage.GetFileTitle();
        dbImages.m_BLOBImage.m_dwDataLength = fileStatus.m_size;

        HGLOBAL hGlobal		= GlobalAlloc(GPTR,fileStatus.m_size);
        dbImages.m_BLOBImage.m_hData = GlobalLock(hGlobal);

        fileImage.Read(dbImages.m_BLOBImage.m_hData,fileStatus.m_size);

        dbImages.SetFieldDirty(&dbImages.m_BLOBImage);
        dbImages.SetFieldNull(&dbImages.m_BLOBImage,FALSE);
        dbImages.Update();

        GlobalUnlock(hGlobal);

        dbImages.Close();
    }
    catch(CException* pE)
    {
        pE->ReportError();
        pE->Delete();
    }

Suggested fix:
Please, tell me how should I insert blob data to the MySQL database through the MFC ODBC api.
[26 Mar 2004 3:44] Arto Hakola
If the compiled application is in UNICODE, inserting blobs doesn't work?
If the application is compiled as MSBC, blob's can be inserted to the database?
[26 Jan 2005 18:54] Jorge del Conde
Verified using VC7
[26 Oct 2005 4:07] Peter Harvey
We do not support UNICODE in c/odbc v3 (MyODBC) at this time. The plan is to support UNICODE in c/odbc v5.

We have had issues with the BLOB type. Please try c/odbc v3.51.12 and lets us know if you have success or failure. You can get it from www.mysql.com downloads or get a patched version (has fix for SQLDriverConnect) at;

ftp.mysql.com/pub/mysql/hidden/connectors/odbc
[27 Nov 2005 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[10 May 2006 17:48] F.José Sen
You can't add binary data with release 3.51.06, 3.51.12 and 3.51.13.

When you call to rs.Update() an exception with the message "General driver defined error" is raised.
[29 May 2013 12:57] Bogdan Degtyariov
I'm closing this bug because I can not continue without feedback from the reporter. If you have new info, please reopen the report.