]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/dbtable.cpp
Added missing newline for Windows debug output
[wxWidgets.git] / src / common / dbtable.cpp
index c6bc966f6d01c065e12e937e1a9b1194ab789dc1..3e3349915935a9a01bbc9c11e866c314818a3ee7 100644 (file)
@@ -434,7 +434,7 @@ void wxDbTable::setCbValueForColumn(int columnIndex)
             if (colDefs[columnIndex].Null)
                 colDefs[columnIndex].CbValue = SQL_NULL_DATA;
             else
-                if (colDefs[columnIndex].SqlCtype == SQL_C_CHAR)
+                if (colDefs[columnIndex].SqlCtype == SQL_C_WXCHAR)
                     colDefs[columnIndex].CbValue = SQL_NTS;
                 else
                     colDefs[columnIndex].CbValue = SQL_LEN_DATA_AT_EXEC(colDefs[columnIndex].SzDataObj);
@@ -779,7 +779,7 @@ bool wxDbTable::Open(bool checkPrivileges, bool checkTableExists)
         // reliable!
         if (// *(pDb->dbInf.accessibleTables) == 'N' &&
             !pDb->TablePrivileges(tableName,wxT("SELECT"), pDb->GetUsername(), pDb->GetUsername(), tablePath))
-            s = wxT("Current logged in user does not have sufficient privileges to access this table.\n");
+            s = wxT("Connecting user does not have sufficient privileges to access this table.\n");
     }
 
     if (!s.IsEmpty())
@@ -998,7 +998,7 @@ void wxDbTable::BuildDeleteStmt(wxString &pSqlStmt, int typeOfDel, const wxStrin
                 // Get the ROWID value.  If not successful retreiving the ROWID,
                 // simply fall down through the code and build the WHERE clause
                 // based on the key fields.
-                if (SQLGetData(hstmt, (UWORD)(noCols+1), SQL_C_CHAR, (UCHAR*) rowid, wxDB_ROWID_LEN, &cb) == SQL_SUCCESS)
+                if (SQLGetData(hstmt, (UWORD)(noCols+1), SQL_C_WXCHAR, (UCHAR*) rowid, sizeof(rowid), &cb) == SQL_SUCCESS)
                 {
                     pSqlStmt += wxT("ROWID = '");
                     pSqlStmt += rowid;
@@ -1216,7 +1216,7 @@ void wxDbTable::BuildUpdateStmt(wxString &pSqlStmt, int typeOfUpd, const wxStrin
                 // Get the ROWID value.  If not successful retreiving the ROWID,
                 // simply fall down through the code and build the WHERE clause
                 // based on the key fields.
-                if (SQLGetData(hstmt, (UWORD)(noCols+1), SQL_C_CHAR, (UCHAR*) rowid, wxDB_ROWID_LEN, &cb) == SQL_SUCCESS)
+                if (SQLGetData(hstmt, (UWORD)(noCols+1), SQL_C_WXCHAR, (UCHAR*) rowid, sizeof(rowid), &cb) == SQL_SUCCESS)
                 {
                     pSqlStmt += wxT("ROWID = '");
                     pSqlStmt += rowid;
@@ -1283,7 +1283,7 @@ void wxDbTable::BuildWhereClause(wxString &pWhereClause, int typeOfWhere,
             }
             pWhereClause += pDb->SQLColumnName(colDefs[colNo].ColName);
 
-            if (useLikeComparison && (colDefs[colNo].SqlCtype == SQL_C_CHAR))
+            if (useLikeComparison && (colDefs[colNo].SqlCtype == SQL_C_WXCHAR))
                 pWhereClause += wxT(" LIKE ");
             else
                 pWhereClause += wxT(" = ");
@@ -1291,6 +1291,8 @@ void wxDbTable::BuildWhereClause(wxString &pWhereClause, int typeOfWhere,
             switch(colDefs[colNo].SqlCtype)
             {
                 case SQL_C_CHAR:
+                case SQL_C_WCHAR:
+                //case SQL_C_WXCHAR:  SQL_C_WXCHAR is covered by either SQL_C_CHAR or SQL_C_WCHAR
                     colValue.Printf(wxT("'%s'"), (UCHAR FAR *) colDefs[colNo].PtrDataObj);
                     break;
                 case SQL_C_SHORT:
@@ -1395,7 +1397,7 @@ bool wxDbTable::CreateTable(bool attemptDrop)
         switch(colDefs[i].DbDataType)
         {
             case DB_DATA_TYPE_VARCHAR:
-                cout << pDb->GetTypeInfVarchar().TypeName << wxT("(") << colDefs[i].SzDataObj << wxT(")");
+                cout << pDb->GetTypeInfVarchar().TypeName << wxT("(") << (int)(colDefs[i].SzDataObj / sizeof(wxChar)) << wxT(")");
                 break;
             case DB_DATA_TYPE_INTEGER:
                 cout << pDb->GetTypeInfInteger().TypeName;
@@ -1457,7 +1459,7 @@ bool wxDbTable::CreateTable(bool attemptDrop)
 //            colDefs[i].DbDataType == DB_DATA_TYPE_BLOB)
         {
             wxString s;
-            s.Printf(wxT("(%d)"), colDefs[i].SzDataObj);
+            s.Printf(wxT("(%d)"), (int)(colDefs[i].SzDataObj / sizeof(wxChar)));
             sqlStmt += s;
         }
 
@@ -1531,7 +1533,7 @@ bool wxDbTable::CreateTable(bool attemptDrop)
                     colDefs[i].DbDataType ==  DB_DATA_TYPE_VARCHAR)
                 {
                     wxString s;
-                    s.Printf(wxT("(%d)"), colDefs[i].SzDataObj);
+                    s.Printf(wxT("(%d)"), (int)(colDefs[i].SzDataObj / sizeof(wxChar)));
                     sqlStmt += s;
                 }
             }
@@ -1673,7 +1675,7 @@ bool wxDbTable::CreateIndex(const wxString &idxName, bool unique, UWORD noIdxCol
             if (found)
             {
                 ok = pDb->ModifyColumn(tableName, pIdxDefs[i].ColName,
-                                        colDefs[j].DbDataType, colDefs[j].SzDataObj,
+                                        colDefs[j].DbDataType, (int)(colDefs[j].SzDataObj / sizeof(wxChar)),
                                         wxT("NOT NULL"));
 
                 if (!ok)
@@ -1735,7 +1737,7 @@ bool wxDbTable::CreateIndex(const wxString &idxName, bool unique, UWORD noIdxCol
             if ( colDefs[j].DbDataType ==  DB_DATA_TYPE_VARCHAR)
             {
                 wxString s;
-                s.Printf(wxT("(%d)"), colDefs[i].SzDataObj);
+                s.Printf(wxT("(%d)"), (int)(colDefs[i].SzDataObj / sizeof(wxChar)));
                 sqlStmt += s;
             }
         }
@@ -2090,6 +2092,8 @@ bool wxDbTable::IsColNull(UWORD colNo) const
     switch(colDefs[colNo].SqlCtype)
     {
         case SQL_C_CHAR:
+        case SQL_C_WCHAR:
+        //case SQL_C_WXCHAR:  SQL_C_WXCHAR is covered by either SQL_C_CHAR or SQL_C_WCHAR
             return(((UCHAR FAR *) colDefs[colNo].PtrDataObj)[0] == 0);
         case SQL_C_SSHORT:
             return((  *((SWORD *) colDefs[colNo].PtrDataObj))   == 0);
@@ -2173,6 +2177,8 @@ void wxDbTable::ClearMemberVar(UWORD colNo, bool setToNull)
     switch(colDefs[colNo].SqlCtype)
     {
         case SQL_C_CHAR:
+        case SQL_C_WCHAR:
+        //case SQL_C_WXCHAR:  SQL_C_WXCHAR is covered by either SQL_C_CHAR or SQL_C_WCHAR
             ((UCHAR FAR *) colDefs[colNo].PtrDataObj)[0]    = 0;
             break;
         case SQL_C_SSHORT:
@@ -2271,7 +2277,7 @@ void wxDbTable::SetColDefs(UWORD index, const wxString &fieldName, int dataType,
     colDefs[index].DbDataType       = dataType;
     colDefs[index].PtrDataObj       = pData;
     colDefs[index].SqlCtype         = cType;
-    colDefs[index].SzDataObj        = size;
+    colDefs[index].SzDataObj        = size;  //TODO: glt ??? * sizeof(wxChar) ???
     colDefs[index].KeyField         = keyField;
     colDefs[index].DerivedCol       = derivedCol;
     // Derived columns by definition would NOT be "Insertable" or "Updateable"
@@ -2309,13 +2315,13 @@ wxDbColDataPtr* wxDbTable::SetColDefs(wxDbColInf *pColInfs, UWORD numCols)
             switch (pColInfs[index].dbDataType)
             {
                 case DB_DATA_TYPE_VARCHAR:
-                   pColDataPtrs[index].PtrDataObj = new wxChar[pColInfs[index].bufferLength+1];
-                   pColDataPtrs[index].SzDataObj  = pColInfs[index].columnSize;
-                   pColDataPtrs[index].SqlCtype   = SQL_C_CHAR;
+                   pColDataPtrs[index].PtrDataObj = new wxChar[pColInfs[index].bufferSize+(1*sizeof(wxChar))];
+                   pColDataPtrs[index].SzDataObj  = pColInfs[index].bufferSize+(1*sizeof(wxChar));
+                   pColDataPtrs[index].SqlCtype   = SQL_C_WXCHAR;
                    break;
                 case DB_DATA_TYPE_INTEGER:
                     // Can be long or short
-                    if (pColInfs[index].bufferLength == sizeof(long))
+                    if (pColInfs[index].bufferSize == sizeof(long))
                     {
                       pColDataPtrs[index].PtrDataObj = new long;
                       pColDataPtrs[index].SzDataObj  = sizeof(long);
@@ -2330,7 +2336,7 @@ wxDbColDataPtr* wxDbTable::SetColDefs(wxDbColInf *pColInfs, UWORD numCols)
                     break;
                 case DB_DATA_TYPE_FLOAT:
                     // Can be float or double
-                    if (pColInfs[index].bufferLength == sizeof(float))
+                    if (pColInfs[index].bufferSize == sizeof(float))
                     {
                         pColDataPtrs[index].PtrDataObj = new float;
                         pColDataPtrs[index].SzDataObj  = sizeof(float);
@@ -2483,12 +2489,12 @@ bool wxDbTable::Refresh(void)
     if (CanUpdByROWID())
     {
         SDWORD cb;
-        wxChar   rowid[wxDB_ROWID_LEN+1];
+        wxChar rowid[wxDB_ROWID_LEN+1];
 
         // Get the ROWID value.  If not successful retreiving the ROWID,
         // simply fall down through the code and build the WHERE clause
         // based on the key fields.
-        if (SQLGetData(hstmt, (UWORD)(noCols+1), SQL_C_CHAR, (UCHAR*) rowid, wxDB_ROWID_LEN, &cb) == SQL_SUCCESS)
+        if (SQLGetData(hstmt, (UWORD)(noCols+1), SQL_C_WXCHAR, (UCHAR*) rowid, sizeof(rowid), &cb) == SQL_SUCCESS)
         {
             whereClause += pDb->SQLTableName(queryTableName);
 //            whereClause += queryTableName;
@@ -2739,7 +2745,7 @@ void wxDbTable::SetCol(const int colNo, const wxVariant val)
             case SQL_VARCHAR:
                 csstrncpyt((wxChar *)(colDefs[colNo].PtrDataObj),
                            val.GetString().c_str(),
-                           colDefs[colNo].SzDataObj-1);
+                           colDefs[colNo].SzDataObj-1);  //TODO: glt ??? * sizeof(wxChar) ???
                 break;
             case SQL_C_LONG:
             case SQL_C_SLONG: