From 5d59e67a7bcbe633410cd78afc91ba82271f1294 Mon Sep 17 00:00:00 2001 From: George Tasker Date: Fri, 18 May 2001 18:32:33 +0000 Subject: [PATCH] Added compile-time check to be sure that wxUSE_ODBC is set to 1 before attempting to compile this program, and error out telling the user to change the setting if they want to compile this program git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10212 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- demos/dbbrowse/browsedb.cpp | 4 ++++ samples/db/dbtest.cpp | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/demos/dbbrowse/browsedb.cpp b/demos/dbbrowse/browsedb.cpp index b8b20b7a7d..3506574c26 100644 --- a/demos/dbbrowse/browsedb.cpp +++ b/demos/dbbrowse/browsedb.cpp @@ -34,6 +34,10 @@ // - darf nur einmal im Projekte definiert werden ?? Extra Databasse Klasse ? wxDbConnectInf DbConnectInf; // Für DBase +#if wxUSE_ODBC + #error Demo cannot be compiled unless setup.h has wxUSE_ODBC set to 1 +#endif + //---------------------------------------------------------------------------------------- extern WXDLLEXPORT_DATA(wxDbList*) PtrBegDbList; /* from db.cpp, used in getting back error results from db connections */ diff --git a/samples/db/dbtest.cpp b/samples/db/dbtest.cpp index 64219c122d..89b4c14ffb 100644 --- a/samples/db/dbtest.cpp +++ b/samples/db/dbtest.cpp @@ -54,6 +54,12 @@ IMPLEMENT_APP(DatabaseDemoApp) extern wxChar ListDB_Selection[]; /* Used to return the first column value for the selected line from the listDB routines */ extern wxChar ListDB_Selection2[]; /* Used to return the second column value for the selected line from the listDB routines */ + +#if !wxUSE_ODBC + #error Sample cannot be compiled unless setup.h has wxUSE_ODBC set to 1 +#endif + + const char *GetExtendedDBErrorMsg(wxDb *pDb, char *ErrFile, int ErrLine) { static wxString msg; @@ -1171,11 +1177,21 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event) if (widgetName == pDataTypesBtn->GetName()) { CheckSupportForAllDataTypes(wxGetApp().READONLY_DB); + return; } // Data types Button if (widgetName == pDbDiagsBtn->GetName()) { +/* +strcpy(wxGetApp().Contact->Addr1,"12345678901234567890"); +//wxString sqlStmt = "UPDATE CONTACTS set ADDRESS1='1234567890ABCEFG' where NAME='12345'"; +//if (wxGetApp().Contact->GetDb()->ExecSql(sqlStmt)) +if (wxGetApp().Contact->UpdateWhere("NAME = '12345'")) +wxGetApp().Contact->GetDb()->CommitTrans(); +else +wxGetApp().Contact->GetDb()->RollbackTrans(); +*/ DisplayDbDiagnostics(wxGetApp().READONLY_DB); return; } @@ -1602,7 +1618,7 @@ bool CeditorDlg::Save() } else { - // Some other unexpexted error occurred + // Some other unexpected error occurred wxString tStr; tStr = wxT("Database insert failed\n\n"); tStr += GetExtendedDBErrorMsg(wxGetApp().Contact->GetDb(),__FILE__,__LINE__); @@ -1612,6 +1628,7 @@ bool CeditorDlg::Save() } else // mode == mEdit { + wxGetApp().Contact->GetDb()->RollbackTrans(); wxGetApp().Contact->whereStr.Printf("NAME = '%s'",saveName.c_str()); if (!wxGetApp().Contact->UpdateWhere(wxGetApp().Contact->whereStr)) { -- 2.45.2