diff --git a/samples/db/dbtest.cpp b/samples/db/dbtest.cpp index 9a28a5ddad..06dc1c7b12 100644 --- a/samples/db/dbtest.cpp +++ b/samples/db/dbtest.cpp @@ -149,15 +149,12 @@ bool DatabaseDemoApp::OnInit() delete DbConnectInf; } - READONLY_DB = wxDbGetConnection(DbConnectInf); if (READONLY_DB == 0) { wxMessageBox(wxT("Unable to connect to the data source.\n\nCheck the name of your data source to verify it has been correctly entered/spelled.\n\nWith some databases, the user name and password must\nbe created with full rights to the CONTACT table prior to making a connection\n(using tools provided by the database manufacturer)"), wxT("DB CONNECTION ERROR..."),wxOK | wxICON_EXCLAMATION); DemoFrame->BuildParameterDialog(NULL); - DbConnectInf->SetDsn(""); - DbConnectInf->SetUid(""); - DbConnectInf->SetPassword(""); + delete DbConnectInf; wxMessageBox(wxT("Now exiting program.\n\nRestart program to try any new settings."),wxT("Notice..."),wxOK | wxICON_INFORMATION); return(FALSE); } @@ -1656,7 +1653,9 @@ END_EVENT_TABLE() // CqueryDlg() constructor -CqueryDlg::CqueryDlg(wxWindow *parent, wxDb *pDb, wxChar *tblName[], wxChar *pWhereArg) : wxDialog (parent, QUERY_DIALOG, wxT("Query"), wxPoint(-1, -1), wxSize(480, 360)) +CqueryDlg::CqueryDlg(wxWindow *parent, wxDb *pDb, wxChar *tblName[], + const wxString &pWhereArg) : + wxDialog (parent, QUERY_DIALOG, wxT("Query"), wxPoint(-1, -1), wxSize(480, 360)) { wxBeginBusyCursor(); @@ -1667,8 +1666,8 @@ CqueryDlg::CqueryDlg(wxWindow *parent, wxDb *pDb, wxChar *tblName[], wxChar *pWh pDB = pDb; // Initialize the WHERE clause from the string passed in - pWhere = pWhereArg; // Save a pointer to the output buffer - if (wxStrlen(pWhere) > (unsigned int)DB_MAX_WHERE_CLAUSE_LEN) // Check the length of the buffer passed in + pWhere = pWhereArg; // Save a pointer to the output buffer + if (pWhere.Length() > (unsigned int)DB_MAX_WHERE_CLAUSE_LEN) // Check the length of the buffer passed in { wxString s; s.Printf(wxT("Maximum where clause length exceeded.\nLength must be less than %d"), DB_MAX_WHERE_CLAUSE_LEN+1); @@ -1757,7 +1756,7 @@ CqueryDlg::CqueryDlg(wxWindow *parent, wxDb *pDb, wxChar *tblName[], wxChar *pWh pQueryHintMsg->SetLabel(langQRY_EQ); - pQuerySqlWhereMtxt->SetValue(pWhere); + pQuerySqlWhereMtxt->SetValue(pWhere.c_str()); wxEndBusyCursor(); @@ -1955,7 +1954,7 @@ void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event) if (!ValidateWhereClause()) return; // Copy the where clause to the output buffer and exit - wxStrcpy(pWhere, pQuerySqlWhereMtxt->GetValue()); + pWhere = pQuerySqlWhereMtxt->GetValue(); Close(); return; } // Done button diff --git a/samples/db/dbtest.h b/samples/db/dbtest.h index 59d56bbdf0..87911415e9 100644 --- a/samples/db/dbtest.h +++ b/samples/db/dbtest.h @@ -431,7 +431,7 @@ class CqueryDlg : public wxDialog wxDbColInf *colInf; // Column inf. returned by db->GetColumns() wxDbTable *dbTable; // generic wxDbTable object for attaching to the table to query wxChar *masterTableName; // Name of the table that 'dbTable' will be associated with - wxChar *pWhere; // A pointer to the storage for the resulting where clause + wxString pWhere; // A pointer to the storage for the resulting where clause wxDb *pDB; public: @@ -470,7 +470,7 @@ class CqueryDlg : public wxDialog wxTextCtrl *pFocusTxt; - CqueryDlg(wxWindow *parent, wxDb *pDb, wxChar *tblName[], wxChar *pWhereArg); + CqueryDlg(wxWindow *parent, wxDb *pDb, wxChar *tblName[], const wxString &pWhereArg); ~CqueryDlg(); void OnButton( wxCommandEvent &event );