Problem with ODBC/dbtest sample

Udo Baumgart ubit.de at gmx.de
Mon Dec 11 03:36:52 PST 2006


Hi,

i tried to compile the odbc sample. It is NOT working under Windows XP.
I am using wxWidgets 2.6.3 with Code::Blocks 1.0 RC 2 with the MinGW.

I tried the ODBC sample code from the manual too: It doesn't work!
wxwidgets:
---------------------------------------------------------------
DbConnectInf = new wxDbConnectInf(NULL,
                                     wxT("VALID ODBC DNS"),
                                     wxT("VALID DATABASE USER"),
                                     wxT("VALID PASSWORD"));

// Error checking....
if (!DbConnectInf || !DbConnectInf->GetHenv())
{
    return HandleError(wxT("DB ENV ERROR: Cannot allocate ODBC env  
handle"));
}
db = wxDbGetConnection(DbConnectInf);
if (!db)
{
     return HandleError(wxT("CONNECTION ERROR - Cannot get DB connection"));
}

-------------------------------------------------------------------

This fails (wxDbGetConnection always returns NULL). If i try to open the
database with the following code (instead of wxDbGetConnection), everything
works fine:
---------------------------------------------------------
     db = new wxDb(DbConnectInf->GetHenv(),false);
     bool open = db->Open(wxT("VALID ODBC DNS"),wxT("VALID DATABASE  
USER"),wxT("VALID PASSWORD"),false);
-----------------------------------------------------

Strange, isn't it?

Is there a change between older versions of wxWidgets and 2.6.3? Or is  
there an error in the odbc part of wxWidgets?

Ciao, Udo

P.S.: I am using MySQL 5.0.23, myODBC 3.51 and an unicode build of  
wxWidgets 2.6.3




More information about the wx-users mailing list