/***** 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)
{
if (!initialize(pwxDb, tblName, numColumns, tempQryTblName, qryOnly, tblPath))
cleanup();
} // wxDbTable::wxDbTable()
+#endif // WXWIN_COMPATIBILITY_2_4
/********** wxDbTable::~wxDbTable() **********/
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);
// 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())
// 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;
// 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;
{
// Determine if this column should be included in the WHERE clause
if ((typeOfWhere == DB_WHERE_KEYFIELDS && colDefs[colNo].KeyField) ||
- (typeOfWhere == DB_WHERE_MATCHING && (!IsColNull(colNo))))
+ (typeOfWhere == DB_WHERE_MATCHING && (!IsColNull((UWORD)colNo))))
{
// Skip over timestamp columns
if (colDefs[colNo].SqlCtype == SQL_C_TIMESTAMP)
}
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(" = ");
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:
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;
// 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;
}
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;
}
}
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)
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;
}
}
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);
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:
case SQL_C_USHORT:
*((UWORD*) colDefs[colNo].PtrDataObj) = 0;
break;
+ case SQL_C_LONG:
case SQL_C_SLONG:
*((SDWORD *) colDefs[colNo].PtrDataObj) = 0;
break;
// Loop through the columns setting each member variable to zero
for (i=0; i < noCols; i++)
- ClearMemberVar(i,setToNull);
+ ClearMemberVar((UWORD)i,setToNull);
} // wxDbTable::ClearMemberVars()
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"
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);
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);
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;
{
colDefs[colNo].Null = set;
if (set) // Blank out the values in the member variable
- ClearMemberVar(colNo,false); // Must call with false here, or infinite recursion will happen
+ ClearMemberVar((UWORD)colNo,false); // Must call with false here, or infinite recursion will happen
setCbValueForColumn(colNo);
wxVariant wxDbTable::GetCol(const int colNo) const
{
wxVariant val;
- if ((colNo < noCols) && (!IsColNull(colNo)))
+ if ((colNo < noCols) && (!IsColNull((UWORD)colNo)))
{
switch (colDefs[colNo].SqlCtype)
{
//FIXME: Add proper wxDateTime support to wxVariant..
wxDateTime dateval;
- SetColNull(colNo, val.IsNull());
+ SetColNull((UWORD)colNo, val.IsNull());
if (!val.IsNull())
{
{
//Returns null if invalid!
if (!dateval.ParseDate(val.GetString()))
- SetColNull(colNo, true);
+ SetColNull((UWORD)colNo, true);
}
switch (colDefs[colNo].SqlCtype)
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:
break;
case SQL_C_SHORT:
case SQL_C_SSHORT:
- *(short *)(colDefs[colNo].PtrDataObj) = val.GetLong();
+ *(short *)(colDefs[colNo].PtrDataObj) = (short)val.GetLong();
break;
case SQL_C_ULONG:
*(unsigned long *)(colDefs[colNo].PtrDataObj) = val.GetLong();
*(wxChar *)(colDefs[colNo].PtrDataObj) = val.GetChar();
break;
case SQL_C_USHORT:
- *(unsigned short *)(colDefs[colNo].PtrDataObj) = val.GetLong();
+ *(unsigned short *)(colDefs[colNo].PtrDataObj) = (unsigned short)val.GetLong();
break;
//FIXME: Add proper wxDateTime support to wxVariant..
case SQL_C_DATE:
DATE_STRUCT *dataptr =
(DATE_STRUCT *)colDefs[colNo].PtrDataObj;
- dataptr->year = dateval.GetYear();
- dataptr->month = dateval.GetMonth()+1;
- dataptr->day = dateval.GetDay();
+ dataptr->year = (SWORD)dateval.GetYear();
+ dataptr->month = (UWORD)(dateval.GetMonth()+1);
+ dataptr->day = (UWORD)dateval.GetDay();
}
break;
case SQL_C_TIME:
{
TIMESTAMP_STRUCT *dataptr =
(TIMESTAMP_STRUCT *)colDefs[colNo].PtrDataObj;
- dataptr->year = dateval.GetYear();
- dataptr->month = dateval.GetMonth()+1;
- dataptr->day = dateval.GetDay();
+ dataptr->year = (SWORD)dateval.GetYear();
+ dataptr->month = (UWORD)(dateval.GetMonth()+1);
+ dataptr->day = (UWORD)dateval.GetDay();
dataptr->hour = dateval.GetHour();
dataptr->minute = dateval.GetMinute();
{
if (colDefs[i].KeyField)
{
- SetColNull(i, false);
+ SetColNull((UWORD)i, false);
memcpy(colDefs[i].PtrDataObj, blkptr, colDefs[i].SzDataObj);
blkptr += colDefs[i].SzDataObj;
}