]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/db/listdb.cpp
Incomplete wxUSE_* warning fix.
[wxWidgets.git] / samples / db / listdb.cpp
index 5714c9125c5d5176bea9b4e656f1f8597b4d58d1..aa73cc1f8df049317d1620958cfa201ffe8878d7 100644 (file)
@@ -202,8 +202,10 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, const wxString &windowTitle, const wxSt
     if (!lookup->Open())
     {
         wxString tStr;
     if (!lookup->Open())
     {
         wxString tStr;
-        tStr.Printf(wxT("Unable to open the table '%s'."), tableName);
-        wxMessageBox(tStr, wxT("ODBC Error..."));
+        tStr.Printf(wxT("Unable to open the table '%s'."), tableName.c_str());
+        wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),lookup->GetDb(),__TFILE__,__LINE__),
+                    wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+
         Close();
         return;
     }
         Close();
         return;
     }
@@ -212,7 +214,11 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, const wxString &windowTitle, const wxSt
     lookup->SetWhereClause(where);
     if (!lookup->Query())
     {
     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;
     }
         Close();
         return;
     }
@@ -267,7 +273,7 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, const wxString &windowTitle, const wxSt
 // in the lookup window.
 //
 ClookUpDlg::ClookUpDlg(wxWindow *parent, const wxString &windowTitle, const wxString &tableName,
 // in the lookup window.
 //
 ClookUpDlg::ClookUpDlg(wxWindow *parent, const wxString &windowTitle, const wxString &tableName,
-                       const wxString &dispCol1, const wxString &dispCol2, 
+                       const wxString &dispCol1, const wxString &dispCol2,
                        const wxString &where, const wxString &orderBy,
                        wxDb *pDb, const wxString &defDir, bool distinctValues,
                        const wxString &selectStmt, int maxLenCol1, bool allowOk)
                        const wxString &where, const wxString &orderBy,
                        wxDb *pDb, const wxString &defDir, bool distinctValues,
                        const wxString &selectStmt, int maxLenCol1, bool allowOk)
@@ -309,7 +315,7 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, const wxString &windowTitle, const wxSt
     if (!lookup2->Open())
     {
         wxString tStr;
     if (!lookup2->Open())
     {
         wxString tStr;
-        tStr.Printf(wxT("Unable to open the table '%s'."),tableName);
+        tStr.Printf(wxT("Unable to open the table '%s'."),tableName.c_str());
         tStr += GetExtendedDBErrorMsg2(pDb,__TFILE__,__LINE__);
         wxMessageBox(tStr,wxT("ODBC Error..."));
         Close();
         tStr += GetExtendedDBErrorMsg2(pDb,__TFILE__,__LINE__);
         wxMessageBox(tStr,wxT("ODBC Error..."));
         Close();
@@ -318,10 +324,12 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, const wxString &windowTitle, const wxSt
 
     // If displaying 2 columns, determine the maximum length of column1
     int maxColLen;
 
     // 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
     {
         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))
         {
         maxColLen = LOOKUP_COL_LEN;
         if (wxStrlen(dispCol2))
         {
@@ -337,14 +345,23 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, const wxString &windowTitle, const wxSt
             }
             if (!lookup2->QueryBySqlStmt(q))
             {
             }
             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
                 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 +370,11 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, const wxString &windowTitle, const wxSt
     {
         if (!lookup2->QueryBySqlStmt(selectStmt))
         {
     {
         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;
         }
             Close();
             return;
         }
@@ -364,7 +385,11 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, const wxString &windowTitle, const wxSt
         lookup2->SetWhereClause(where);
         if (!lookup2->Query(false, distinctValues))
         {
         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;
         }
             Close();
             return;
         }