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
This commit is contained in:
George Tasker 2001-05-18 18:32:33 +00:00
parent 06b32ebe4f
commit 5d59e67a7b
2 changed files with 22 additions and 1 deletions

View File

@ -34,6 +34,10 @@
// - darf nur einmal im Projekte definiert werden ?? Extra Databasse Klasse ? // - darf nur einmal im Projekte definiert werden ?? Extra Databasse Klasse ?
wxDbConnectInf DbConnectInf; // Für DBase 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 */ extern WXDLLEXPORT_DATA(wxDbList*) PtrBegDbList; /* from db.cpp, used in getting back error results from db connections */

View File

@ -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_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 */ 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) const char *GetExtendedDBErrorMsg(wxDb *pDb, char *ErrFile, int ErrLine)
{ {
static wxString msg; static wxString msg;
@ -1171,11 +1177,21 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
if (widgetName == pDataTypesBtn->GetName()) if (widgetName == pDataTypesBtn->GetName())
{ {
CheckSupportForAllDataTypes(wxGetApp().READONLY_DB); CheckSupportForAllDataTypes(wxGetApp().READONLY_DB);
return; return;
} // Data types Button } // Data types Button
if (widgetName == pDbDiagsBtn->GetName()) 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); DisplayDbDiagnostics(wxGetApp().READONLY_DB);
return; return;
} }
@ -1602,7 +1618,7 @@ bool CeditorDlg::Save()
} }
else else
{ {
// Some other unexpexted error occurred // Some other unexpected error occurred
wxString tStr; wxString tStr;
tStr = wxT("Database insert failed\n\n"); tStr = wxT("Database insert failed\n\n");
tStr += GetExtendedDBErrorMsg(wxGetApp().Contact->GetDb(),__FILE__,__LINE__); tStr += GetExtendedDBErrorMsg(wxGetApp().Contact->GetDb(),__FILE__,__LINE__);
@ -1612,6 +1628,7 @@ bool CeditorDlg::Save()
} }
else // mode == mEdit else // mode == mEdit
{ {
wxGetApp().Contact->GetDb()->RollbackTrans();
wxGetApp().Contact->whereStr.Printf("NAME = '%s'",saveName.c_str()); wxGetApp().Contact->whereStr.Printf("NAME = '%s'",saveName.c_str());
if (!wxGetApp().Contact->UpdateWhere(wxGetApp().Contact->whereStr)) if (!wxGetApp().Contact->UpdateWhere(wxGetApp().Contact->whereStr))
{ {