]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/db.cpp
Improved selection mode handling in wxGrid::SelectBlock
[wxWidgets.git] / src / common / db.cpp
index 06dc95d96f708490433b48ad5ec3db04c14c34cb..12f614d4c5a039207e866e535cdc9098152113bd 100644 (file)
@@ -47,7 +47,7 @@
 #endif
 
 #ifdef DBDEBUG_CONSOLE
 #endif
 
 #ifdef DBDEBUG_CONSOLE
-    #include <iostream.h>
+    #include "wx/ioswrap.h"
 #endif
 
 #ifdef    __BORLANDC__
 #endif
 
 #ifdef    __BORLANDC__
@@ -61,6 +61,7 @@
         #include "wx/list.h"
         #include "wx/utils.h"
         #include "wx/msgdlg.h"
         #include "wx/list.h"
         #include "wx/utils.h"
         #include "wx/msgdlg.h"
+        #include "wx/log.h"
     #endif
     #include "wx/filefn.h"
     #include "wx/wxchar.h"
     #endif
     #include "wx/filefn.h"
     #include "wx/wxchar.h"
@@ -897,7 +898,7 @@ void wxDB::Close(void)
         {
             s.sprintf("(%-20s)     tableID:[%6lu]     pDb:[%p]", tiu->tableName,tiu->tableID,tiu->pDb);
             s2.sprintf("Orphaned found using pDb:[%p]",this);
         {
             s.sprintf("(%-20s)     tableID:[%6lu]     pDb:[%p]", tiu->tableName,tiu->tableID,tiu->pDb);
             s2.sprintf("Orphaned found using pDb:[%p]",this);
-            wxMessageBox (s,s2);
+            wxLogDebug (s.c_str(),s2.c_str());
         }
         pNode = pNode->Next();
     }
         }
         pNode = pNode->Next();
     }
@@ -961,7 +962,7 @@ bool wxDB::DispAllErrors(HENV aHenv, HDBC aHdbc, HSTMT aHstmt)
         }
 
 #ifdef __WXDEBUG__
         }
 
 #ifdef __WXDEBUG__
-        wxMessageBox(odbcErrMsg.GetData(),"DEBUG MESSAGE from DispAllErrors()");
+        wxLogDebug(odbcErrMsg.GetData(),"DEBUG MESSAGE from DispAllErrors()");
 #endif
     }
 
 #endif
     }
 
@@ -1673,12 +1674,20 @@ wxColInf *wxDB::GetColumns(char *tableName[], const char *userID)
                         GetData( 9, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].decimalDigits,0,                        &cb);
                         GetData(10, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].numPrecRadix, 0,                        &cb);
                         GetData(11, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].nullable,     0,                        &cb);
                         GetData( 9, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].decimalDigits,0,                        &cb);
                         GetData(10, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].numPrecRadix, 0,                        &cb);
                         GetData(11, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].nullable,     0,                        &cb);
-                        GetData(12, SQL_C_CHAR,   (UCHAR*)  colInf[colNo].remarks,         254+1,                    &cb);
+                        GetData(12, SQL_C_CHAR,   (UCHAR*)  colInf[colNo].remarks,      254+1,                    &cb);
 
                         // Determine the wxDB data type that is used to represent the native data type of this data source
                         colInf[colNo].dbDataType = 0;
                         if (!wxStricmp(typeInfVarchar.TypeName,colInf[colNo].typeName))
 
                         // Determine the wxDB data type that is used to represent the native data type of this data source
                         colInf[colNo].dbDataType = 0;
                         if (!wxStricmp(typeInfVarchar.TypeName,colInf[colNo].typeName))
+                        {
+                            if (colInf[colNo].columnSize < 1)
+                            {
+                               // IODBC does not return a correct columnSize, so we set
+                               // columnSize = bufferLength if no column size was returned
+                               colInf[colNo].columnSize = colInf[colNo].bufferLength;
+                            }
                             colInf[colNo].dbDataType = DB_DATA_TYPE_VARCHAR;
                             colInf[colNo].dbDataType = DB_DATA_TYPE_VARCHAR;
+                        }
                         else if (!wxStricmp(typeInfInteger.TypeName,colInf[colNo].typeName))
                             colInf[colNo].dbDataType = DB_DATA_TYPE_INTEGER;
                         else if (!wxStricmp(typeInfFloat.TypeName,colInf[colNo].typeName))
                         else if (!wxStricmp(typeInfInteger.TypeName,colInf[colNo].typeName))
                             colInf[colNo].dbDataType = DB_DATA_TYPE_INTEGER;
                         else if (!wxStricmp(typeInfFloat.TypeName,colInf[colNo].typeName))
@@ -1843,7 +1852,15 @@ wxColInf *wxDB::GetColumns(char *tableName, int *numCols, const char *userID)
                     // Determine the wxDB data type that is used to represent the native data type of this data source
                     colInf[colNo].dbDataType = 0;
                     if (!wxStricmp(typeInfVarchar.TypeName,colInf[colNo].typeName))
                     // Determine the wxDB data type that is used to represent the native data type of this data source
                     colInf[colNo].dbDataType = 0;
                     if (!wxStricmp(typeInfVarchar.TypeName,colInf[colNo].typeName))
+                    {
+                        if (colInf[colNo].columnSize < 1)
+                        {
+                             // IODBC does not return a correct columnSize, so we set
+                             // columnSize = bufferLength if no column size was returned
+                             colInf[colNo].columnSize = colInf[colNo].bufferLength;
+                        }
                         colInf[colNo].dbDataType = DB_DATA_TYPE_VARCHAR;
                         colInf[colNo].dbDataType = DB_DATA_TYPE_VARCHAR;
+                    }
                     else if (!wxStricmp(typeInfInteger.TypeName,colInf[colNo].typeName))
                         colInf[colNo].dbDataType = DB_DATA_TYPE_INTEGER;
                     else if (!wxStricmp(typeInfFloat.TypeName,colInf[colNo].typeName))
                     else if (!wxStricmp(typeInfInteger.TypeName,colInf[colNo].typeName))
                         colInf[colNo].dbDataType = DB_DATA_TYPE_INTEGER;
                     else if (!wxStricmp(typeInfFloat.TypeName,colInf[colNo].typeName))