Page 1 of 1

Can't take data from table

Posted: Tue Aug 24, 2010 12:32 pm
by Starosta
Hi
I have problem with this code.

Code: Select all

class gtTreeCtrl : public wxTreeCtrl
{
    private:
        wxDbTable* m_RootDbTable;
        wxDbTable* m_ChildrenDbTable;
    public:
        gtTreeCtrl(){};
        gtTreeCtrl(wxWindow *parent, const wxWindowID id,
               const wxPoint& pos, const wxSize& size,
               long style);

        virtual ~gtTreeCtrl         (){};
        void SetRootDbTable         (wxDbTable* RootDbTable){m_RootDbTable = RootDbTable;};
        void SetChildrenDbTable     (wxDbTable* ChildrenDbTable){m_ChildrenDbTable = ChildrenDbTable;};
        bool GetRootNodes           (const wxString &ColumnName);
        bool GetChildrenNodes       (const wxString &ColumnName);
};

 /*

TreeCtrl->SetRootDbTable(Pracownicy); //Somewhere in app
 TreeCtrl->GetRootNodes(wxT("DZIAL"));
*/

bool gtTreeCtrl::GetRootNodes(const wxString &ColumnName)
{
    wxString whereStr;

    if (m_RootDbTable->Open() == false)
		return(false);

    whereStr  = wxT("SELECT DISTINCT ");
    whereStr += ColumnName;
    whereStr += wxT(" FROM ");
    whereStr += m_RootDbTable->GetTableName();

    m_RootDbTable->QueryBySqlStmt(whereStr);

    if (!m_RootDbTable->Query())
    {
        wxString tStr;
        tStr = wxT("Can't return data from m_RootDbTable\n\n");
        wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),m_RootDbTable->GetDb(),__TFILE__,__LINE__),
                     wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);

        return(false);
    }

    while (m_RootDbTable->GetNext())
    {
        wxTreeItemId rootId = AddRoot(wxT("Trans"),-1, -1);
        SetItemText(rootId, m_RootDbTable->Dzial);
        return(true);
    }
    return(true);
} //gtTreeCtrl::GetRootNodes()
When I try compile this code, My compiler give me this error:

G:\Programowanie\CB Raporter\GtControls.cpp||In member function `bool gtTreeCtrl::GetRootNodes(const wxString&)':|
G:\Programowanie\CB Raporter\GtControls.cpp|55|error: 'class wxDbTable' has no member named 'Dzial'|
||=== Build finished: 1 errors, 0 warnings ===|

What I do wrong?
In this case is all ok:

Code: Select all

bool SetPracownicyPanel::PutData()
{
    wxDateTime date;
    wxString tStr, tStr1;
    tStr.Printf(wxT("%d/%d/%d"),Pracownicy->Data.year, Pracownicy->Data.month, Pracownicy->Data.day);
    date.ParseDate(tStr);
    DatePickerCtrl1     ->SetValue(date);
    tStr1.Printf(wxT("%d"),Pracownicy->Nr_Kj);
    Nr_Kj_TextCtrl      ->SetValue(tStr1);
    Imie_TextCtrl       ->SetValue(Pracownicy->Imie);
    Nazwisko_TextCtrl   ->SetValue(Pracownicy->Nazwisko);
    Dzial_Choice        ->SetStringSelection(Pracownicy->Dzial);
    return true;
}  // SetPracownicyPanel::PutData()

Posted: Tue Aug 24, 2010 3:37 pm
by Auria
First, it's important to know that wxODBC is being removed from newer versions of wxWidgets because it's been unmaintained for years. So I would just recommend looking for another way to access the database

Posted: Tue Aug 24, 2010 5:13 pm
by Mojo
Auria wrote:First, it's important to know that wxODBC is being removed from newer versions of wxWidgets because it's been unmaintained for years. So I would just recommend looking for another way to access the database
It's a great pity but it doesn't mean wxODBC is dead, I hope it will useful even after being removed form newer version, cause it works ok separately
http://forums.wxwidgets.org/viewtopic.php?t=28458

Posted: Sun Aug 29, 2010 5:00 pm
by evstevemd
Mojo wrote:
Auria wrote:First, it's important to know that wxODBC is being removed from newer versions of wxWidgets because it's been unmaintained for years. So I would just recommend looking for another way to access the database
It's a great pity but it doesn't mean wxODBC is dead, I hope it will useful even after being removed form newer version, cause it works ok separately
http://forums.wxwidgets.org/viewtopic.php?t=28458
give a shot to DatabaseLayer