+//////////////////////////////////////////////////////////////
+// wxDbGrid support functions
+//////////////////////////////////////////////////////////////
+
+void wxDbTable::SetRowMode(const rowmode_t rowmode)
+{
+ if (!m_hstmtGridQuery)
+ {
+ m_hstmtGridQuery = GetNewCursor(false,false);
+ if (!bindCols(*m_hstmtGridQuery))
+ return;
+ }
+
+ m_rowmode = rowmode;
+ switch (m_rowmode)
+ {
+ case WX_ROW_MODE_QUERY:
+ SetCursor(m_hstmtGridQuery);
+ break;
+ case WX_ROW_MODE_INDIVIDUAL:
+ SetCursor(hstmtDefault);
+ break;
+ default:
+ wxASSERT(0);
+ }
+} // wxDbTable::SetRowMode()
+
+
+wxVariant wxDbTable::GetColumn(const int colNumber) const
+{
+ wxVariant val;
+ if ((colNumber < m_numCols) && (!IsColNull((UWORD)colNumber)))
+ {
+ switch (colDefs[colNumber].SqlCtype)
+ {
+#if wxUSE_UNICODE
+ #if defined(SQL_WCHAR)
+ case SQL_WCHAR:
+ #endif
+ #if defined(SQL_WVARCHAR)
+ case SQL_WVARCHAR:
+ #endif
+#endif
+ case SQL_CHAR:
+ case SQL_VARCHAR:
+ val = (wxChar *)(colDefs[colNumber].PtrDataObj);
+ break;
+ case SQL_C_LONG:
+ case SQL_C_SLONG:
+ val = *(long *)(colDefs[colNumber].PtrDataObj);
+ break;
+ case SQL_C_SHORT:
+ case SQL_C_SSHORT:
+ val = (long int )(*(short *)(colDefs[colNumber].PtrDataObj));
+ break;
+ case SQL_C_ULONG:
+ val = (long)(*(unsigned long *)(colDefs[colNumber].PtrDataObj));
+ break;
+ case SQL_C_TINYINT:
+ val = (long)(*(wxChar *)(colDefs[colNumber].PtrDataObj));
+ break;
+ case SQL_C_UTINYINT:
+ val = (long)(*(wxChar *)(colDefs[colNumber].PtrDataObj));
+ break;
+ case SQL_C_USHORT:
+ val = (long)(*(UWORD *)(colDefs[colNumber].PtrDataObj));
+ break;
+ case SQL_C_DATE:
+ val = (DATE_STRUCT *)(colDefs[colNumber].PtrDataObj);
+ break;
+ case SQL_C_TIME:
+ val = (TIME_STRUCT *)(colDefs[colNumber].PtrDataObj);
+ break;
+ case SQL_C_TIMESTAMP:
+ val = (TIMESTAMP_STRUCT *)(colDefs[colNumber].PtrDataObj);
+ break;
+ case SQL_C_DOUBLE:
+ val = *(double *)(colDefs[colNumber].PtrDataObj);
+ break;
+ default:
+ assert(0);
+ }
+ }
+ return val;
+} // wxDbTable::GetCol()
+
+
+void wxDbTable::SetColumn(const int colNumber, const wxVariant val)
+{
+ //FIXME: Add proper wxDateTime support to wxVariant..
+ wxDateTime dateval;
+
+ SetColNull((UWORD)colNumber, val.IsNull());
+
+ if (!val.IsNull())
+ {
+ if ((colDefs[colNumber].SqlCtype == SQL_C_DATE)
+ || (colDefs[colNumber].SqlCtype == SQL_C_TIME)
+ || (colDefs[colNumber].SqlCtype == SQL_C_TIMESTAMP))
+ {
+ //Returns null if invalid!
+ if (!dateval.ParseDate(val.GetString()))
+ SetColNull((UWORD)colNumber, true);
+ }
+
+ switch (colDefs[colNumber].SqlCtype)
+ {
+#if wxUSE_UNICODE
+ #if defined(SQL_WCHAR)
+ case SQL_WCHAR:
+ #endif
+ #if defined(SQL_WVARCHAR)
+ case SQL_WVARCHAR:
+ #endif
+#endif
+ case SQL_CHAR:
+ case SQL_VARCHAR:
+ csstrncpyt((wxChar *)(colDefs[colNumber].PtrDataObj),
+ val.GetString().c_str(),
+ colDefs[colNumber].SzDataObj-1); //TODO: glt ??? * sizeof(wxChar) ???
+ break;
+ case SQL_C_LONG:
+ case SQL_C_SLONG:
+ *(long *)(colDefs[colNumber].PtrDataObj) = val;
+ break;
+ case SQL_C_SHORT:
+ case SQL_C_SSHORT:
+ *(short *)(colDefs[colNumber].PtrDataObj) = (short)val.GetLong();
+ break;
+ case SQL_C_ULONG:
+ *(unsigned long *)(colDefs[colNumber].PtrDataObj) = val.GetLong();
+ break;
+ case SQL_C_TINYINT:
+ *(wxChar *)(colDefs[colNumber].PtrDataObj) = val.GetChar();
+ break;
+ case SQL_C_UTINYINT:
+ *(wxChar *)(colDefs[colNumber].PtrDataObj) = val.GetChar();
+ break;
+ case SQL_C_USHORT:
+ *(unsigned short *)(colDefs[colNumber].PtrDataObj) = (unsigned short)val.GetLong();
+ break;
+ //FIXME: Add proper wxDateTime support to wxVariant..
+ case SQL_C_DATE:
+ {
+ DATE_STRUCT *dataptr =
+ (DATE_STRUCT *)colDefs[colNumber].PtrDataObj;