]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/db/listdb.cpp
Factory some of wxFilterClassFactory into a base class.
[wxWidgets.git] / samples / db / listdb.cpp
index ff932873336c8711239982b46c3ed3141552cd0f..58bbaa84acb6532d1a917e1355c11b3dc2f151e1 100644 (file)
 // SYNOPSIS STOP
 */
 
-#ifdef __GNUG__
-#pragma implementation "listdb.h"
-#endif
-
 #include  "wx/wxprec.h"
 
 #ifdef    __BORLANDC__
@@ -79,7 +75,7 @@ extern wxApp *DatabaseDemoApp;
 
 /*
  * This function will return the exact string(s) from the database engine
- * indicating all error conditions which have just occured during the
+ * indicating all error conditions which have just occurred during the
  * last call to the database engine.
  *
  * This demo uses the returned string by displaying it in a wxMessageBox.  The
@@ -203,7 +199,9 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, const wxString &windowTitle, const wxSt
     {
         wxString tStr;
         tStr.Printf(wxT("Unable to open the table '%s'."), tableName.c_str());
-        wxMessageBox(tStr, wxT("ODBC Error..."));
+        wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),lookup->GetDb(),__TFILE__,__LINE__),
+                    wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+
         Close();
         return;
     }
@@ -212,7 +210,11 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, const wxString &windowTitle, const wxSt
     lookup->SetWhereClause(where);
     if (!lookup->Query())
     {
-        wxMessageBox(wxT("ODBC error during Query()"), wxT("ODBC Error..."));
+        wxString tStr;
+        tStr = wxT("ODBC error during Query()\n\n");
+        wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),lookup->GetDb(),__TFILE__,__LINE__),
+                    wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+
         Close();
         return;
     }
@@ -318,10 +320,12 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, const wxString &windowTitle, const wxSt
 
     // If displaying 2 columns, determine the maximum length of column1
     int maxColLen;
-    if (maxLenCol1)
+    if (maxLenCol1 > 0)
         maxColLen = col1Len = maxLenCol1;  // user passed in max col length for column 1
     else
     {
+        // NOTE: Some databases (Firebird/Interbase) cannot handle the "fn" and "MAX()" functions
+
         maxColLen = LOOKUP_COL_LEN;
         if (wxStrlen(dispCol2))
         {
@@ -337,14 +341,23 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, const wxString &windowTitle, const wxSt
             }
             if (!lookup2->QueryBySqlStmt(q))
             {
-                wxMessageBox(wxT("ODBC error during QueryBySqlStmt()"),wxT("ODBC Error..."));
+                wxString tStr;
+                tStr = wxT("ODBC error during QueryBySqlStmt()\n\n");
+                wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),lookup2->GetDb(),__TFILE__,__LINE__),
+                            wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+
                 Close();
                 return;
             }
             if (lookup2->GetNext())
                 maxColLen = col1Len = wxAtoi(lookup2->lookupCol1);
             else
-                wxMessageBox(wxT("ODBC error during GetNext()"),wxT("ODBC Error..."));
+            {
+                wxString tStr;
+                tStr = wxT("ODBC error during GetNext()\n\n");
+                wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),lookup2->GetDb(),__TFILE__,__LINE__),
+                            wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+            }
         }
     }
 
@@ -353,7 +366,11 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, const wxString &windowTitle, const wxSt
     {
         if (!lookup2->QueryBySqlStmt(selectStmt))
         {
-            wxMessageBox(wxT("ODBC error during QueryBySqlStmt()"),wxT("ODBC Error..."));
+            wxString tStr;
+            tStr = wxT("ODBC error during QueryBySqlStmt()\n\n");
+            wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),lookup2->GetDb(),__TFILE__,__LINE__),
+                        wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+
             Close();
             return;
         }
@@ -364,7 +381,11 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, const wxString &windowTitle, const wxSt
         lookup2->SetWhereClause(where);
         if (!lookup2->Query(false, distinctValues))
         {
-            wxMessageBox(wxT("ODBC error during Query()"),wxT("ODBC Error..."));
+            wxString tStr;
+            tStr = wxT("ODBC error during Query()\n\n");
+            wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),lookup2->GetDb(),__TFILE__,__LINE__),
+                        wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+
             Close();
             return;
         }
@@ -492,6 +513,6 @@ void ClookUpDlg::OnCommand(wxWindow& win, wxCommandEvent& WXUNUSED(event))
 
     }
 
-};  // ClookUpDlg::OnCommand
+}  // ClookUpDlg::OnCommand
 
 // *********************************** listdb.cpp **********************************