Author Topic: Database problem  (Read 2519 times)

Offline baboo

  • Multiple posting newcomer
  • *
  • Posts: 15
Database problem
« on: December 01, 2005, 12:28:28 pm »
Hello
If this topic is not in the ritght place, please tell me where can I find some info on this subject.
I started my wx & CB experience a month ago and it goes really nice. But I have this problem with connecting to a postgreSQL database. I used ODBC, I defined a DSN for a database, but it doesnt want to connect.
I will attach the sourcecode, if any1 can help me.
Thank you!


    wxDbConnectInf *DbConnectInf;
    DbConnectInf = new wxDbConnectInf(NULL, "PostgreSQL", "admin", "admin", "");

    if (!DbConnectInf->AllocHenv())
    {
        wxMessageBox("Unable to allocate an ODBC environment handle",
                     "DB CONNECTION ERROR", wxOK | wxICON_EXCLAMATION);
        return;
    }

    wxDb *sampleDB = new wxDb(DbConnectInf->GetHenv());
    if (sampleDB->Open("PostgreSQL","admin","admin"))
        wxMessageBox("open!");

    if (sampleDB->IsOpen())
        wxMessageBox("Hooray! database is open!");
    else
        wxMessageBox("Still wrong...");

    delete DbConnectInf;



I only have "still wrong" message! :(