Results 1 to 2 of 2

Thread: [RESOLVED] SQLExecuteDirect fails on Blob data type

  1. #1
    Join Date
    Feb 2008

    resolved [RESOLVED] SQLExecuteDirect fails on Blob data type

    Hi friends,

    I am a newbie to SQL world. I am writing an application to set and read blob data into and from database.

    My code sequence is as given below:
    Ret = SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE, &sqlEnv );
    Ret = SQLAllocHandle( SQL_HANDLE_DBC, sqlEnv, &sqlDbc );
    Ret = SQLSetConnectAttr( sqlDbc, SQL_ATTR_ODBC_VERSION, ( SQLPOINTER )SQL_OV_ODBC3, 0 );
    Ret = SQLDriverConnectW( sqlDbc, NULL, ptcConnString, nLen, NULL, 0, NULL, SQL_DRIVER_NOPROMPT );
    Ret = SQLAllocHandle( SQL_HANDLE_STMT, sqlDbc, &sqlStmt );
    Ret = SQLSetConnectAttr( sqlDbc, SQL_ATTR_AUTOCOMMIT, reinterpret_cast<void*>(SQL_AUTOCOMMIT_OFF), 0 );
    QLULEN uBlobSize = 100;
    const int nRows = 1;
    int* pnOID = new int[ nRows ];
    ZeroMemory( pnOID, nRows );
    BYTE* pbyValBlb = new BYTE[uBlobSize];
    ZeroMemory( pbyValBlb, uBlobSize );

    SQLINTEGER* idxOID = new SQLINTEGER[ nRows ];
    ZeroMemory( idxOID, nRows );
    SQLINTEGER* idxValBlb = new SQLINTEGER[ nRows ];
    ZeroMemory( idxValBlb, nRows );

    SQLINTEGER qnFetchPtr = 0;
    Ret = SQLExecDirect(sqlStmt, _T( "SELECT value_blob FROM image_binary" ), SQL_NTS);
    Ret = SQLBindCol( sqlStmt, 1, SQL_C_BINARY, pbyValBlb, uBlobSize, idxValBlb );
    Ret = SQLFetch( sqlStmt );

    In this code the SQLExecDirect function always fails. I am trying to access the blob data set in DB. Can any one help me in this case. Do we need to take care anything when we deal with blob data type.
    My table schema is :
    create table image_binary
    oid bigint,
    value_blob blob

    It works fine when I am reading the bigint value.

    Thanks in advance,
    Last edited by jackjon; 02-13-2008 at 11:52 PM.

  2. #2
    Join Date
    Feb 2008


    Hi friends, I got my problem fixed.

    The issue was with the ODBC driver. The driver installation was not successful. I copied the driver dll in to the Windows\system32 folder and restarted server and machine. Now its working fine.


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center