Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
Been searching for a solution to this online for nearly two days. I have tried many versions of logic to fix this issue, very good examples and samples implemented from Code Project, but nothing working. It takes me a long time to ask for help, I find I learn far better by trying to solve the problem myself (tracing into the Microsoft Code etc).

MFC Application is to allow internal personnel to upload PDF files into a database. On submission, the files are emailed to administration for processing. All of this works fine except when trying to upload a file size greater than (I found reference to 400KB).

I need the files in the DB (SQL 2008)for auditing purposes, otherwise I would find a solution based on using the file system. I have tried the SQL Server and SQL Server Native Client 10.0 interfaces but both present the same issue.

The code as shown has been broken out so the file information is stored in a separate table. I tried to get the BLOB SQL table as simple as possible (ID, reference to file information, and file data itself.

Code is simple enough:
C++
if( !m_dsExpPDF.IsOpen() )
        m_dsExpPDF.Open();

    m_dsExpPDF.AddNew();

    m_dsExpPDF.m_BLOB_ID = m_dsExpBlob.m_ID;
    m_dsExpPDF.m_BLOB_FILE.m_dwDataLength = ((SQLUINTEGER)fileStatus.m_size);
    HGLOBAL hGlobal     = GlobalAlloc(GPTR,m_dsExpPDF.m_BLOB_FILE.m_dwDataLength);
    m_dsExpPDF.m_BLOB_FILE.m_hData = GlobalLock(hGlobal);

    UINT numRead = fileScan.Read(m_dsExpPDF.m_BLOB_FILE.m_hData,m_dsExpPDF.m_BLOB_FILE.m_dwDataLength);
    //UINT numRead = fileScan.Read(m_dsExpBlob.m_BLOB.,fileStatus.m_size);
    m_dsExpPDF.SetFieldDirty(&m_dsExpPDF.m_BLOB_FILE);
    m_dsExpPDF.SetFieldNull(&m_dsExpPDF.m_BLOB_FILE,FALSE);

    m_dsExpPDF.Update();
    GlobalUnlock(hGlobal);

If anyone can assist with a solution it would be greatly appreciated.

Thanks to Shekar Narayanan for his contribution that my code is based on: Using CLongBinary for Blobs.
Posted
Updated 7-Sep-13 9:13am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900