X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/049977d042858eaef70b0720ab101b1b40c5e308..015e69f36dfbc469eef59456f973d0567e865d70:/samples/db/dbtest.cpp?ds=sidebyside diff --git a/samples/db/dbtest.cpp b/samples/db/dbtest.cpp index 9a28a5ddad..532b4bbf20 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); } @@ -552,7 +549,7 @@ bool Ccontact::CreateIndexes(void) */ bool Ccontact::FetchByName(const wxString &name) { - whereStr.Printf(wxT("NAME = '%s'"),name); + whereStr.Printf(wxT("NAME = '%s'"),name.c_str()); SetWhereClause(whereStr.c_str()); SetOrderByClause(wxT("")); @@ -1030,7 +1027,7 @@ bool CeditorDlg::Initialize() if (Contact->GetDb()->Dbms() != dbmsPOSTGRES && Contact->GetDb()->Dbms() != dbmsMY_SQL) { - Contact->whereStr.Printf(wxT("NAME = (SELECT MIN(NAME) FROM %s)"),Contact->GetTableName()); + Contact->whereStr.Printf(wxT("NAME = (SELECT MIN(NAME) FROM %s)"),Contact->GetTableName().c_str()); // NOTE: (const wxChar*) returns a pointer which may not be valid later, so this is short term use only Contact->SetWhereClause(Contact->whereStr); } @@ -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