#endif
#ifdef DBDEBUG_CONSOLE
-#if wxUSE_IOSTREAMH
- #include <iostream.h>
-#else
- #include <iostream>
-#endif
#include "wx/ioswrap.h"
#endif
#include "wx/dbtable.h"
-#ifdef __UNIX__
-// The HPUX preprocessor lines below were commented out on 8/20/97
-// because macros.h currently redefines DEBUG and is unneeded.
-// # ifdef HPUX
-// # include <macros.h>
-// # endif
-# ifdef LINUX
-# include <sys/minmax.h>
-# endif
-#endif
-
ULONG lastTableID = 0;
#ifdef __WXDEBUG__
+ #include "wx/thread.h"
+
wxList TablesInUse;
+ wxCriticalSection csTablesInUse;
#endif
} // wxDbTable::wxDbTable()
-/***** DEPRECATED: use wxDbTable::wxDbTable() format above *****/
-#if WXWIN_COMPATIBILITY_2_4
-wxDbTable::wxDbTable(wxDb *pwxDb, const wxString &tblName, const UWORD numColumns,
- const wxChar *qryTblName, bool qryOnly, const wxString &tblPath)
-{
- wxString tempQryTblName;
- tempQryTblName = qryTblName;
- if (!initialize(pwxDb, tblName, numColumns, tempQryTblName, qryOnly, tblPath))
- cleanup();
-} // wxDbTable::wxDbTable()
-#endif // WXWIN_COMPATIBILITY_2_4
-
-
/********** wxDbTable::~wxDbTable() **********/
wxDbTable::~wxDbTable()
{
tableInUse->tableName = tblName;
tableInUse->tableID = tableID;
tableInUse->pDb = pDb;
- TablesInUse.Append(tableInUse);
+ {
+ wxCriticalSectionLocker lock(csTablesInUse);
+ TablesInUse.Append(tableInUse);
+ }
#endif
pDb->WriteSqlLog(s);
bool found = false;
wxList::compatibility_iterator pNode;
- pNode = TablesInUse.GetFirst();
- while (pNode && !found)
{
- if (((wxTablesInUse *)pNode->GetData())->tableID == tableID)
+ wxCriticalSectionLocker lock(csTablesInUse);
+ pNode = TablesInUse.GetFirst();
+ while (!found && pNode)
{
- found = true;
- delete (wxTablesInUse *)pNode->GetData();
- TablesInUse.Erase(pNode);
+ if (((wxTablesInUse *)pNode->GetData())->tableID == tableID)
+ {
+ found = true;
+ delete (wxTablesInUse *)pNode->GetData();
+ TablesInUse.Erase(pNode);
+ }
+ else
+ pNode = pNode->GetNext();
}
- else
- pNode = pNode->GetNext();
}
if (!found)
{
/********** wxDbTable::bindCols() **********/
bool wxDbTable::bindCols(HSTMT cursor)
{
- static SQLLEN cb;
-
// Bind each column of the table to a memory address for fetching data
UWORD i;
for (i = 0; i < m_numCols; i++)
{
- cb = colDefs[i].CbValue;
if (SQLBindCol(cursor, (UWORD)(i+1), colDefs[i].SqlCtype, (UCHAR*) colDefs[i].PtrDataObj,
- colDefs[i].SzDataObj, &cb ) != SQL_SUCCESS)
+ colDefs[i].SzDataObj, &colDefs[i].CbValue ) != SQL_SUCCESS)
return (pDb->DispAllErrors(henv, hdbc, cursor));
}
// Completed successfully
return true;
-
} // wxDbTable::bindCols()
case SQL_C_WCHAR:
#endif
//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[colNumber].PtrDataObj);
+ colValue.Printf(wxT("'%s'"), GetDb()->EscapeSqlChars((wxChar *)colDefs[colNumber].PtrDataObj).c_str());
break;
case SQL_C_SHORT:
case SQL_C_SSHORT: