wxDB and Blobs Issue, wxMSW 2.6.3

Thomas Zehbe tz at ingenion.de
Tue Oct 3 07:56:50 PDT 2006


Hi Amid,

Am Dienstag, 3. Oktober 2006 11:04 schrieb Amit:
> Hello Thomas,
>
> Thanks for ur reply.
>
> I tested it by increasing the buffer size (even bigger than the blob
> size itself), then also it returns me the same size it used to return
> before.
>
> The code I had sent works pretty well for smaller sized blobs but fails
> to retrieve huge blobs.
Maby the buffer is still too small. As I have some Blobs (Pictures of about 
1,5MB in my test database I created the following statements to retrieve 
them:
**************
wxDb* pDb = igGetDbApp().pDB;
SDWORD cb;     ULONG reqQty; 
wxString sqlStmt; 
sqlStmt.Printf(_T("SELECT fzbild from fahrzeug where id=%i"), mFzgRec->id);
// Perform the query 
if (!pDb->ExecSql(sqlStmt.c_str())) 
{ 
    // ERROR 
    return; 
} 
// Request the first row of the result set 
if (!pDb->GetNext()) 
{ 
    // ERROR 
    return; 
} 
// Read column #1 of the row returned by the call to ::GetNext() 
// and return the value in 'reqQty' 
char* buf;
buf = (char*)malloc(2048000);
if (!pDb->GetData(1, SQL_C_BINARY, buf, 2048000, &cb)) 
{ 
    wxString tStr;
    tStr = wxT("ODBC Fehler nach GetData()\n\n");
    wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),
                 igGetDbApp().pDB,__TFILE__,__LINE__),
    wxT("ODBC Fehler..."),wxOK | wxICON_EXCLAMATION);
}
else wxLogMessage(_T("size is %i"), cb);
return;
************
This code works. As I select a single field I first set the colindex to "0", 
wich was wrong an resulted in bookmark concerned error messages. Changing it 
to 1 works, if the buffer is large enough. If not the GetData() return false 
and a "buffer too small message" is displayed.

If the buffer is large enough, cb was set to 2048000 instead of the actual 
blobsize.
You should add the error display code to see what happens.
BTW. I'm using PostgreSQL 8.01.

Good luck!

Thomas

>
> Any help would be higly appreciated.
>
> Regards,
> Amit
>
> Thomas Zehbe wrote:
> > I assume that if the provided buffer is to short, then this happens (from
> > wxWidgets help):
> > cbReturned
> > Pointer to the buffer containing the length of the actual data returned.
> > If this value comes back as SQL_NULL_DATA, then the wxDb::GetData call
> > has failed.
> > Regards,
> >
> > Thomas
> >
> > > May be, I am not doing the right way!
> > > Thanks in advance.
> > >
> > > Regards
> > > -Amit
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> > > For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
> >
> > --
> > Dipl.-Ing. Thomas Zehbe
> > INGENION GmbH
> > Kuhweide 6
> > 31552 Apelern
> > Fon: 05043 / 40 57 90 4
> > Fax: 05043 / 40 57 90 7
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> > For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org

-- 
Dipl.-Ing. Thomas Zehbe
INGENION GmbH
Kuhweide 6
31552 Apelern
Fon: 05043 / 40 57 90 4
Fax: 05043 / 40 57 90 7




More information about the wx-users mailing list