#include <wx/wx.h>
#endif //WX_PRECOMP
-#ifdef __WXGTK__
+#if defined(__WXGTK__) || defined(__WXX11__)
#include "db.xpm"
#endif
//extern wxDbList WXDLLEXPORT *PtrBegDbList; /* from db.cpp, used in getting back error results from db connections */
+#if wxUSE_NEW_GRID
+#include <wx/grid.h>
+#include <wx/generic/gridctrl.h>
+#include <wx/dbgrid.h>
+
+#define CHOICEINT
+#endif
+
#include "dbtest.h" /* Header file for this demonstration program */
#include "listdb.h" /* Code to support the "Lookup" button on the editor dialog */
#endif
-const char *GetExtendedDBErrorMsg(wxDb *pDb, char *ErrFile, int ErrLine)
-{
- static wxString msg;
- msg = wxT("");
-
- wxString tStr;
-
- if (ErrFile || ErrLine)
- {
- msg += wxT("File: ");
- msg += ErrFile;
- msg += wxT(" Line: ");
- tStr.Printf(wxT("%d"),ErrLine);
- msg += tStr.c_str();
- msg += wxT("\n");
- }
-
- msg.Append (wxT("\nODBC errors:\n"));
- msg += wxT("\n");
-
- // Display errors for this connection
- int i;
- for (i = 0; i < DB_MAX_ERROR_HISTORY; i++)
- {
- if (pDb->errorList[i])
- {
- msg.Append(pDb->errorList[i]);
- if (wxStrcmp(pDb->errorList[i],wxT("")) != 0)
- msg.Append(wxT("\n"));
- // Clear the errmsg buffer so the next error will not
- // end up showing the previous error that have occurred
- wxStrcpy(pDb->errorList[i],wxT(""));
- }
- }
- msg += wxT("\n");
-
- return msg.c_str();
-} // GetExtendedDBErrorMsg
-
-
-bool DataTypeSupported(wxDb *pDb, SWORD datatype)
+bool DataTypeSupported(wxDb *pDb, SWORD datatype, wxString *nativeDataTypeName)
{
wxDbSqlTypeInfo sqlTypeInfo;
bool breakpoint = FALSE;
+ *nativeDataTypeName = wxEmptyString;
if (pDb->GetDataTypeInfo(datatype, sqlTypeInfo))
+ {
+ *nativeDataTypeName = sqlTypeInfo.TypeName;
breakpoint = TRUE;
+ }
return breakpoint;
void CheckSupportForAllDataTypes(wxDb *pDb)
{
+ wxString nativeDataTypeName;
+
wxLogMessage("\nThe following datatypes are supported by the\ndatabase you are currently connected to:");
#ifdef SQL_C_BINARY
- if (DataTypeSupported(pDb,SQL_C_BINARY))
- wxLogMessage("SQL_C_BINARY");
+ if (DataTypeSupported(pDb,SQL_C_BINARY, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_BINARY (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_BIT
- if (DataTypeSupported(pDb,SQL_C_BIT))
- wxLogMessage("SQL_C_BIT");
+ if (DataTypeSupported(pDb,SQL_C_BIT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_BIT (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_BOOKMARK
- if (DataTypeSupported(pDb,SQL_C_BOOKMARK))
- wxLogMessage("SQL_C_BOOKMARK");
+ if (DataTypeSupported(pDb,SQL_C_BOOKMARK, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_BOOKMARK (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_CHAR
- if (DataTypeSupported(pDb,SQL_C_CHAR))
- wxLogMessage("SQL_C_CHAR");
+ if (DataTypeSupported(pDb,SQL_C_CHAR, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_CHAR (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_DATE
- if (DataTypeSupported(pDb,SQL_C_DATE))
- wxLogMessage("SQL_C_DATE");
+ if (DataTypeSupported(pDb,SQL_C_DATE, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_DATE (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_DEFAULT
- if (DataTypeSupported(pDb,SQL_C_DEFAULT))
- wxLogMessage("SQL_C_DEFAULT");
+ if (DataTypeSupported(pDb,SQL_C_DEFAULT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_DEFAULT (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_DOUBLE
- if (DataTypeSupported(pDb,SQL_C_DOUBLE))
- wxLogMessage("SQL_C_DOUBLE");
+ if (DataTypeSupported(pDb,SQL_C_DOUBLE, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_DOUBLE (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_FLOAT
- if (DataTypeSupported(pDb,SQL_C_FLOAT))
- wxLogMessage("SQL_C_FLOAT");
+ if (DataTypeSupported(pDb,SQL_C_FLOAT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_FLOAT (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_GUID
- if (DataTypeSupported(pDb,SQL_C_GUID))
- wxLogMessage("SQL_C_GUID");
+ if (DataTypeSupported(pDb,SQL_C_GUID, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_GUID (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_INTERVAL_DAY
- if (DataTypeSupported(pDb,SQL_C_INTERVAL_DAY))
- wxLogMessage("SQL_C_INTERVAL_DAY");
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_DAY, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_INTERVAL_DAY (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_INTERVAL_DAY_TO_HOUR
- if (DataTypeSupported(pDb,SQL_C_INTERVAL_DAY_TO_HOUR))
- wxLogMessage("SQL_C_INTERVAL_DAY_TO_HOUR");
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_DAY_TO_HOUR, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_INTERVAL_DAY_TO_HOUR (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_INTERVAL_DAY_TO_MINUTE
- if (DataTypeSupported(pDb,SQL_C_INTERVAL_DAY_TO_MINUTE))
- wxLogMessage("SQL_C_INTERVAL_DAY_TO_MINUTE");
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_DAY_TO_MINUTE, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_INTERVAL_DAY_TO_MINUTE (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_INTERVAL_DAY_TO_SECOND
- if (DataTypeSupported(pDb,SQL_C_INTERVAL_DAY_TO_SECOND))
- wxLogMessage("SQL_C_INTERVAL_DAY_TO_SECOND");
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_DAY_TO_SECOND, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_INTERVAL_DAY_TO_SECOND (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_INTERVAL_HOUR
- if (DataTypeSupported(pDb,SQL_C_INTERVAL_HOUR))
- wxLogMessage("SQL_C_INTERVAL_HOUR");
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_HOUR, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_INTERVAL_HOUR (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_INTERVAL_HOUR_TO_MINUTE
- if (DataTypeSupported(pDb,SQL_C_INTERVAL_HOUR_TO_MINUTE))
- wxLogMessage("SQL_C_INTERVAL_HOUR_TO_MINUTE");
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_HOUR_TO_MINUTE, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_INTERVAL_HOUR_TO_MINUTE (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_INTERVAL_HOUR_TO_SECOND
- if (DataTypeSupported(pDb,SQL_C_INTERVAL_HOUR_TO_SECOND))
- wxLogMessage("SQL_C_INTERVAL_HOUR_TO_SECOND");
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_HOUR_TO_SECOND, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_INTERVAL_HOUR_TO_SECOND (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_INTERVAL_MINUTE
- if (DataTypeSupported(pDb,SQL_C_INTERVAL_MINUTE))
- wxLogMessage("SQL_C_INTERVAL_MINUTE");
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_MINUTE, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_INTERVAL_MINUTE (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_INTERVAL_MINUTE_TO_SECOND
- if (DataTypeSupported(pDb,SQL_C_INTERVAL_MINUTE_TO_SECOND))
- wxLogMessage("SQL_C_INTERVAL_MINUTE_TO_SECOND");
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_MINUTE_TO_SECOND, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_INTERVAL_MINUTE_TO_SECOND (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_INTERVAL_MONTH
- if (DataTypeSupported(pDb,SQL_C_INTERVAL_MONTH))
- wxLogMessage("SQL_C_INTERVAL_MONTH");
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_MONTH, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_INTERVAL_MONTH (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_INTERVAL_SECOND
- if (DataTypeSupported(pDb,SQL_C_INTERVAL_SECOND))
- wxLogMessage("SQL_C_INTERVAL_SECOND");
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_SECOND, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_INTERVAL_SECOND (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_INTERVAL_YEAR
- if (DataTypeSupported(pDb,SQL_C_INTERVAL_YEAR))
- wxLogMessage("SQL_C_INTERVAL_YEAR");
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_YEAR, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_INTERVAL_YEAR (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_INTERVAL_YEAR_TO_MONTH
- if (DataTypeSupported(pDb,SQL_C_INTERVAL_YEAR_TO_MONTH))
- wxLogMessage("SQL_C_INTERVAL_YEAR_TO_MONTH");
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_YEAR_TO_MONTH, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_INTERVAL_YEAR_TO_MONTH (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_LONG
- if (DataTypeSupported(pDb,SQL_C_LONG))
- wxLogMessage("SQL_C_LONG");
+ if (DataTypeSupported(pDb,SQL_C_LONG, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_LONG (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_NUMERIC
- if (DataTypeSupported(pDb,SQL_C_NUMERIC))
- wxLogMessage("SQL_C_NUMERIC");
+ if (DataTypeSupported(pDb,SQL_C_NUMERIC, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_NUMERIC (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_SBIGINT
- if (DataTypeSupported(pDb,SQL_C_SBIGINT))
- wxLogMessage("SQL_C_SBIGINT");
+ if (DataTypeSupported(pDb,SQL_C_SBIGINT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_SBIGINT (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_SHORT
- if (DataTypeSupported(pDb,SQL_C_SHORT))
- wxLogMessage("SQL_C_SHORT");
+ if (DataTypeSupported(pDb,SQL_C_SHORT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_SHORT (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_SLONG
- if (DataTypeSupported(pDb,SQL_C_SLONG))
- wxLogMessage("SQL_C_SLONG");
+ if (DataTypeSupported(pDb,SQL_C_SLONG, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_SLONG (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_SSHORT
- if (DataTypeSupported(pDb,SQL_C_SSHORT))
- wxLogMessage("SQL_C_SSHORT");
+ if (DataTypeSupported(pDb,SQL_C_SSHORT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_SSHORT (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_STINYINT
- if (DataTypeSupported(pDb,SQL_C_STINYINT))
- wxLogMessage("SQL_C_STINYINT");
+ if (DataTypeSupported(pDb,SQL_C_STINYINT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_STINYINT (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_TIME
- if (DataTypeSupported(pDb,SQL_C_TIME))
- wxLogMessage("SQL_C_TIME");
+ if (DataTypeSupported(pDb,SQL_C_TIME, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_TIME (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_TIMESTAMP
- if (DataTypeSupported(pDb,SQL_C_TIMESTAMP))
- wxLogMessage("SQL_C_TIMESTAMP");
+ if (DataTypeSupported(pDb,SQL_C_TIMESTAMP, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_TIMESTAMP (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_TINYINT
- if (DataTypeSupported(pDb,SQL_C_TINYINT))
- wxLogMessage("SQL_C_TINYINT");
+ if (DataTypeSupported(pDb,SQL_C_TINYINT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_TINYINT (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_TYPE_DATE
- if (DataTypeSupported(pDb,SQL_C_TYPE_DATE))
- wxLogMessage("SQL_C_TYPE_DATE");
+ if (DataTypeSupported(pDb,SQL_C_TYPE_DATE, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_TYPE_DATE (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_TYPE_TIME
- if (DataTypeSupported(pDb,SQL_C_TYPE_TIME))
- wxLogMessage("SQL_C_TYPE_TIME");
+ if (DataTypeSupported(pDb,SQL_C_TYPE_TIME, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_TYPE_TIME (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_TYPE_TIMESTAMP
- if (DataTypeSupported(pDb,SQL_C_TYPE_TIMESTAMP))
- wxLogMessage("SQL_C_TYPE_TIMESTAMP");
+ if (DataTypeSupported(pDb,SQL_C_TYPE_TIMESTAMP, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_TYPE_TIMESTAMP (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_UBIGINT
- if (DataTypeSupported(pDb,SQL_C_UBIGINT))
- wxLogMessage("SQL_C_UBIGINT");
+ if (DataTypeSupported(pDb,SQL_C_UBIGINT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_UBIGINT (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_ULONG
- if (DataTypeSupported(pDb,SQL_C_ULONG))
- wxLogMessage("SQL_C_ULONG");
+ if (DataTypeSupported(pDb,SQL_C_ULONG, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_ULONG (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_USHORT
- if (DataTypeSupported(pDb,SQL_C_USHORT))
- wxLogMessage("SQL_C_USHORT");
+ if (DataTypeSupported(pDb,SQL_C_USHORT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_USHORT (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_UTINYINT
- if (DataTypeSupported(pDb,SQL_C_UTINYINT))
- wxLogMessage("SQL_C_UTINYINT");
+ if (DataTypeSupported(pDb,SQL_C_UTINYINT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_UTINYINT (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_C_VARBOOKMARK
- if (DataTypeSupported(pDb,SQL_C_VARBOOKMARK))
- wxLogMessage("SQL_C_VARBOOKMARK");
+ if (DataTypeSupported(pDb,SQL_C_VARBOOKMARK, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_VARBOOKMARK (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
// Extended SQL types
#ifdef SQL_DATE
- if (DataTypeSupported(pDb,SQL_DATE))
- wxLogMessage("SQL_DATE");
+ if (DataTypeSupported(pDb,SQL_DATE, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_DATE (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_INTERVAL
- if (DataTypeSupported(pDb,SQL_INTERVAL))
- wxLogMessage("SQL_INTERVAL");
+ if (DataTypeSupported(pDb,SQL_INTERVAL, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_INTERVAL (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_TIME
- if (DataTypeSupported(pDb,SQL_TIME))
- wxLogMessage("SQL_TIME");
+ if (DataTypeSupported(pDb,SQL_TIME, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_TIME (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_TIMESTAMP
- if (DataTypeSupported(pDb,SQL_TIMESTAMP))
- wxLogMessage("SQL_TIMESTAMP");
+ if (DataTypeSupported(pDb,SQL_TIMESTAMP, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_TIMESTAMP (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_LONGVARCHAR
- if (DataTypeSupported(pDb,SQL_LONGVARCHAR))
- wxLogMessage("SQL_LONGVARCHAR");
+ if (DataTypeSupported(pDb,SQL_LONGVARCHAR, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_LONGVARCHAR (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_BINARY
- if (DataTypeSupported(pDb,SQL_BINARY))
- wxLogMessage("SQL_BINARY");
+ if (DataTypeSupported(pDb,SQL_BINARY, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_BINARY (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_VARBINARY
- if (DataTypeSupported(pDb,SQL_VARBINARY))
- wxLogMessage("SQL_VARBINARY");
+ if (DataTypeSupported(pDb,SQL_VARBINARY, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_VARBINARY (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_LONGVARBINARY
- if (DataTypeSupported(pDb,SQL_LONGVARBINARY))
- wxLogMessage("SQL_LONGVARBINARY");
+ if (DataTypeSupported(pDb,SQL_LONGVARBINARY, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_LOGVARBINARY (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_BIGINT
- if (DataTypeSupported(pDb,SQL_BIGINT))
- wxLogMessage("SQL_BIGINT");
+ if (DataTypeSupported(pDb,SQL_BIGINT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_BIGINT (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_TINYINT
- if (DataTypeSupported(pDb,SQL_TINYINT))
- wxLogMessage("SQL_TINYINT");
+ if (DataTypeSupported(pDb,SQL_TINYINT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_TINYINT (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_BIT
- if (DataTypeSupported(pDb,SQL_BIT))
- wxLogMessage("SQL_BIT");
+ if (DataTypeSupported(pDb,SQL_BIT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_BIT (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_GUID
- if (DataTypeSupported(pDb,SQL_GUID))
- wxLogMessage("SQL_GUID");
+ if (DataTypeSupported(pDb,SQL_GUID, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_GUID (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_CHAR
- if (DataTypeSupported(pDb,SQL_CHAR))
- wxLogMessage("SQL_CHAR");
+ if (DataTypeSupported(pDb,SQL_CHAR, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_CHAR (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_INTEGER
- if (DataTypeSupported(pDb,SQL_INTEGER))
- wxLogMessage("SQL_INTEGER");
+ if (DataTypeSupported(pDb,SQL_INTEGER, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_INTEGER (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_SMALLINT
- if (DataTypeSupported(pDb,SQL_SMALLINT))
- wxLogMessage("SQL_SMALLINT");
+ if (DataTypeSupported(pDb,SQL_SMALLINT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_SAMLLINT (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_REAL
- if (DataTypeSupported(pDb,SQL_REAL))
- wxLogMessage("SQL_REAL");
+ if (DataTypeSupported(pDb,SQL_REAL, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_REAL (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_DOUBLE
- if (DataTypeSupported(pDb,SQL_DOUBLE))
- wxLogMessage("SQL_DOUBLE");
+ if (DataTypeSupported(pDb,SQL_DOUBLE, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_DOUBLE (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_NUMERIC
- if (DataTypeSupported(pDb,SQL_NUMERIC))
- wxLogMessage("SQL_NUMERIC");
+ if (DataTypeSupported(pDb,SQL_NUMERIC, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_NUMERIC (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_DATE
- if (DataTypeSupported(pDb,SQL_DATE))
- wxLogMessage("SQL_DATE");
+ if (DataTypeSupported(pDb,SQL_DATE, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_DATE (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_TIME
- if (DataTypeSupported(pDb,SQL_TIME))
- wxLogMessage("SQL_TIME");
+ if (DataTypeSupported(pDb,SQL_TIME, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_TIME (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_TIMESTAMP
- if (DataTypeSupported(pDb,SQL_TIMESTAMP))
- wxLogMessage("SQL_TIMESTAMP");
+ if (DataTypeSupported(pDb,SQL_TIMESTAMP, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_TIMESTAMP (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
#ifdef SQL_VARCHAR
- if (DataTypeSupported(pDb,SQL_VARCHAR))
- wxLogMessage("SQL_VARCHAR");
+ if (DataTypeSupported(pDb,SQL_VARCHAR, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_VARCHAR (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
// UNICODE
#ifdef SQL_C_TCHAR
- if (DataTypeSupported(pDb,SQL_C_TCHAR))
- wxLogMessage("SQL_C_TCHAR (Unicode support is possible)");
+ if (DataTypeSupported(pDb,SQL_C_TCHAR, &nativeDataTypeName))
+ {
+ nativeDataTypeName = "SQL_C_TCHAR (" + nativeDataTypeName;
+ nativeDataTypeName += ")";
+ wxLogMessage(nativeDataTypeName);
+ }
#endif
wxLogMessage("\n");
file_menu->Append(FILE_CREATE, wxT("&Create CONTACT table"));
file_menu->Append(FILE_RECREATE_TABLE, wxT("&Recreate CONTACT table"));
file_menu->Append(FILE_RECREATE_INDEXES, wxT("&Recreate CONTACT indexes"));
+#if wxUSE_NEW_GRID
+ file_menu->Append(FILE_DBGRID_TABLE, wxT("&Open DB Grid example"));
+#endif
file_menu->Append(FILE_EXIT, wxT("E&xit"));
wxMenu *edit_menu = new wxMenu;
} // DatabaseDemoApp::OnInit()
+/*
+* Remove CR or CR/LF from a character string.
+*/
+char* wxRemoveLineTerminator(char* aString)
+{
+ int len = strlen(aString);
+ while (len > 0 && (aString[len-1] == '\r' || aString[len-1] == '\n')) {
+ aString[len-1] = '\0';
+ len--;
+ }
+ return aString;
+}
+
+
bool DatabaseDemoApp::ReadParamFile(Cparameters ¶ms)
{
FILE *paramFile;
wxChar buffer[1000+1];
fgets(buffer, sizeof(params.ODBCSource), paramFile);
- buffer[wxStrlen(buffer)-1] = wxT('\0');
+ wxRemoveLineTerminator(buffer);
wxStrcpy(params.ODBCSource,buffer);
fgets(buffer, sizeof(params.UserName), paramFile);
- buffer[wxStrlen(buffer)-1] = wxT('\0');
+ wxRemoveLineTerminator(buffer);
wxStrcpy(params.UserName,buffer);
fgets(buffer, sizeof(params.Password), paramFile);
- buffer[wxStrlen(buffer)-1] = wxT('\0');
+ wxRemoveLineTerminator(buffer);
wxStrcpy(params.Password,buffer);
fgets(buffer, sizeof(params.DirPath), paramFile);
- buffer[wxStrlen(buffer)-1] = wxT('\0');
+ wxRemoveLineTerminator(buffer);
wxStrcpy(params.DirPath,buffer);
fclose(paramFile);
{
wxEndBusyCursor();
wxString tStr;
- tStr = wxT("Error creating CONTACTS table.\nTable was not created.\n\n");
- tStr += GetExtendedDBErrorMsg(Contact->GetDb(),__FILE__,__LINE__);
- wxMessageBox(tStr,wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+ tStr = wxT("Error creating CONTACTS table.\nTable was not created.\n\n");
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+
success = FALSE;
}
else
{
wxEndBusyCursor();
wxString tStr;
- tStr = wxT("Error creating CONTACTS indexes.\nIndexes will be unavailable.\n\n");
- tStr += GetExtendedDBErrorMsg(Contact->GetDb(),__FILE__,__LINE__);
- wxMessageBox(tStr,wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+ tStr = wxT("Error creating CONTACTS indexes.\nIndexes will be unavailable.\n\n");
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+
success = FALSE;
}
}
EVT_MENU(FILE_CREATE, DatabaseDemoFrame::OnCreate)
EVT_MENU(FILE_RECREATE_TABLE, DatabaseDemoFrame::OnRecreateTable)
EVT_MENU(FILE_RECREATE_INDEXES, DatabaseDemoFrame::OnRecreateIndexes)
+#if wxUSE_NEW_GRID
+ EVT_MENU(FILE_DBGRID_TABLE, DatabaseDemoFrame::OnDbGridTable)
+#endif
EVT_MENU(FILE_EXIT, DatabaseDemoFrame::OnExit)
EVT_MENU(EDIT_PARAMETERS, DatabaseDemoFrame::OnEditParameters)
EVT_MENU(HELP_ABOUT, DatabaseDemoFrame::OnAbout)
{
wxGetApp().Contact->GetDb()->RollbackTrans(); // Make sure the current cursor is in a known/stable state
- if (!wxGetApp().Contact->CreateIndexes(true))
+ if (!wxGetApp().Contact->CreateIndexes(TRUE))
{
while (wxIsBusy())
wxEndBusyCursor();
wxString tStr;
- tStr = wxT("Error creating CONTACTS indexes.\nNew indexes will be unavailable.\n\n");
- tStr += GetExtendedDBErrorMsg(wxGetApp().Contact->GetDb(),__FILE__,__LINE__);
- wxMessageBox(tStr,wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+ tStr = wxT("Error creating CONTACTS indexes.\nNew indexes will be unavailable.\n\n");
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+
}
else
wxMessageBox(wxT("Index(es) were successfully recreated."),wxT("Notice..."),wxOK | wxICON_INFORMATION);
} // DatabaseDemoFrame::OnRecreateIndexes()
+#if wxUSE_NEW_GRID
+void DatabaseDemoFrame::OnDbGridTable(wxCommandEvent& )
+{
+ DbGridFrame *frame = new DbGridFrame(this);
+ if (frame->Initialize())
+ {
+ frame->Show();
+ }
+}
+#endif
+
void DatabaseDemoFrame::OnExit(wxCommandEvent& event)
{
Close();
if (!wxDbFreeConnection(GetDb()))
{
wxString tStr;
- tStr = wxT("Unable to Free the Ccontact data table handle\n\n");
- tStr += GetExtendedDBErrorMsg(GetDb(),__FILE__,__LINE__);
- wxMessageBox(tStr,wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+ tStr = wxT("Unable to Free the Ccontact data table handle\n\n");
+
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
}
}
} // Ccontract destructor
* functions to interface to the data structure used to store records in
* memory, and for all the column definitions that define the table structure
*/
-void Ccontact::SetupColumns()
+void Ccontact::SetupColumns()
{
// NOTE: Columns now are 8 character names, as that is all dBase can support. Longer
// names can be used for other database engines
SetColDefs ( 6,wxT("COUNTRY"), DB_DATA_TYPE_VARCHAR, Country, SQL_C_CHAR, sizeof(Country), FALSE,TRUE);
SetColDefs ( 7,wxT("JOINDATE"), DB_DATA_TYPE_DATE, &JoinDate, SQL_C_TIMESTAMP, sizeof(JoinDate), FALSE,TRUE);
SetColDefs ( 8,wxT("IS_DEV"), DB_DATA_TYPE_INTEGER, &IsDeveloper, SQL_C_BOOLEAN(IsDeveloper), sizeof(IsDeveloper), FALSE,TRUE);
- SetColDefs ( 9,wxT("CONTRIBS"), DB_DATA_TYPE_INTEGER, &Contributions, SQL_C_USHORT, sizeof(Contributions), FALSE,TRUE);
+ SetColDefs ( 9,wxT("CONTRIBS"), DB_DATA_TYPE_INTEGER, &Contributions, SQL_C_UTINYINT, sizeof(Contributions), FALSE,TRUE);
SetColDefs (10,wxT("LINE_CNT"), DB_DATA_TYPE_INTEGER, &LinesOfCode, SQL_C_ULONG, sizeof(LinesOfCode), FALSE,TRUE);
SetColDefs (11,wxT("LANGUAGE"), DB_DATA_TYPE_INTEGER, &NativeLanguage, SQL_C_ENUM, sizeof(NativeLanguage), FALSE,TRUE);
#if wxODBC_BLOB_EXPERIMENT > 0
if (!wxGetApp().Contact->Query())
{
wxString tStr;
- tStr = wxT("ODBC error during Query()\n\n");
- tStr += GetExtendedDBErrorMsg(wxGetApp().Contact->GetDb(),__FILE__,__LINE__);
- wxMessageBox(tStr,wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+ tStr = wxT("ODBC error during Query()\n\n");
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+
SetMode(mView);
return;
}
if (!wxGetApp().Contact->Query())
{
wxString tStr;
- tStr = wxT("ODBC error during Query()\n\n");
- tStr += GetExtendedDBErrorMsg(wxGetApp().Contact->GetDb(),__FILE__,__LINE__);
- wxMessageBox(tStr,wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+ tStr = wxT("ODBC error during Query()\n\n");
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+
return;
}
// Display the first record from the query set
if (!wxGetApp().Contact->Query())
{
wxString tStr;
- tStr = wxT("ODBC error during Query()\n\n");
- tStr += GetExtendedDBErrorMsg(wxGetApp().Contact->GetDb(),__FILE__,__LINE__);
- wxMessageBox(tStr,wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+ tStr = wxT("ODBC error during Query()\n\n");
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
return;
}
if (!wxGetApp().Contact->GetNext())
wxGetApp().DbConnectInf->GetDefaultDir()))
{
wxString tStr;
- tStr.Printf(wxT("Unable to open the table '%s'.\n\nTable may need to be created...?\n\n"),CONTACT_TABLE_NAME);
- tStr += GetExtendedDBErrorMsg(wxGetApp().Contact->GetDb(),__FILE__,__LINE__);
- wxMessageBox(tStr,wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
-
- bool createTable = (wxMessageBox(wxT("Do you wish to try to create/clear the CONTACTS table?"),wxT("Confirm"),wxYES_NO|wxICON_QUESTION) == wxYES);
+ tStr.Printf(wxT("Unable to open the table '%s'. The table may\nneed to be created.\n\nDo you wish to try to create/clear the table?\n\n"),CONTACT_TABLE_NAME);
+ bool createTable = (wxMessageBox(tStr.c_str(),wxT("Confirm"),wxYES_NO|wxICON_QUESTION) == wxYES);
if (!createTable)
{
{
wxString tStr;
tStr.Printf(wxT("Unable to open the table '%s' (likely due to\ninsufficient privileges of the logged in user).\n\n"),CONTACT_TABLE_NAME);
- tStr += GetExtendedDBErrorMsg(wxGetApp().Contact->GetDb(),__FILE__,__LINE__);
- wxMessageBox(tStr,wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
}
else
#endif
{
wxString tStr;
tStr.Printf(wxT("Unable to open the table '%s' as the table\ndoes not appear to exist in the tablespace available\nto the currently logged in user.\n\n"),CONTACT_TABLE_NAME);
- tStr += GetExtendedDBErrorMsg(wxGetApp().Contact->GetDb(),__FILE__,__LINE__);
- wxMessageBox(tStr,wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
}
return FALSE;
if (!wxGetApp().Contact->Query())
{
wxString tStr;
- tStr = wxT("ODBC error during Query()\n\n");
- tStr += GetExtendedDBErrorMsg(wxGetApp().Contact->GetDb(),__FILE__,__LINE__);
- wxMessageBox(tStr,wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+ tStr = wxT("ODBC error during Query()\n\n");
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
return FALSE;
}
}
bool invalid = FALSE;
- int mm,dd,yyyy;
+ int mm = 1,dd = 1,yyyy = 2001;
int first, second;
tStr = pJoinDateTxt->GetValue();
if (result == DB_ERR_INTEGRITY_CONSTRAINT_VIOL)
{
wxString tStr;
- tStr = wxT("A duplicate key value already exists in the table.\nUnable to save record\n\n");
- tStr += GetExtendedDBErrorMsg(wxGetApp().Contact->GetDb(),__FILE__,__LINE__);
- wxMessageBox(tStr,wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+ tStr = wxT("A duplicate key value already exists in the table.\nUnable to save record\n\n");
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
}
else
{
// Some other unexpected error occurred
wxString tStr;
- tStr = wxT("Database insert failed\n\n");
- tStr += GetExtendedDBErrorMsg(wxGetApp().Contact->GetDb(),__FILE__,__LINE__);
- wxMessageBox(tStr,wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+ tStr = wxT("Database insert failed\n\n");
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
}
}
}
if (!wxGetApp().Contact->UpdateWhere(wxGetApp().Contact->whereStr))
{
wxString tStr;
- tStr = wxT("Database update failed\n\n");
- tStr += GetExtendedDBErrorMsg(wxGetApp().Contact->GetDb(),__FILE__,__LINE__);
- wxMessageBox(tStr,wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+ tStr = wxT("Database update failed\n\n");
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
failed = TRUE;
}
}
if (!wxGetApp().Contact->Query())
{
wxString tStr;
- tStr = wxT("ODBC error during Query()\n\n");
- tStr += GetExtendedDBErrorMsg(wxGetApp().Contact->GetDb(),__FILE__,__LINE__);
- wxMessageBox(tStr,wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+ tStr = wxT("ODBC error during Query()\n\n");
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
return(FALSE);
}
// Fill in the fields from the params object
if (wxGetApp().params.ODBCSource && wxStrlen(wxGetApp().params.ODBCSource))
- pParamODBCSourceList->SetStringSelection(wxGetApp().params.ODBCSource);
+ {
+ int index = pParamODBCSourceList->FindString(wxGetApp().params.ODBCSource);
+ if (index != -1)
+ pParamODBCSourceList->SetSelection(index);
+ }
pParamUserNameTxt->SetValue(wxGetApp().params.UserName);
pParamPasswordTxt->SetValue(wxGetApp().params.Password);
pParamDirPathTxt->SetValue(wxGetApp().params.DirPath);
{
wxEndBusyCursor();
wxString tStr;
- tStr = wxT("ODBC error during GetColumns()\n\n");
- tStr += GetExtendedDBErrorMsg(pDb,__FILE__,__LINE__);
- wxMessageBox(tStr,wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+ tStr = wxT("ODBC error during GetColumns()\n\n");
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
return;
}
if (!dbTable->Open())
{
wxString tStr;
- tStr = wxT("ODBC error during Open()\n\n");
- tStr += GetExtendedDBErrorMsg(dbTable->GetDb(),__FILE__,__LINE__);
- wxMessageBox(tStr,wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+ tStr = wxT("ODBC error during Open()\n\n");
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
return;
}
}
}
s += "\n";
+#ifdef __VMS__
+#pragma message disable incboodep
+#endif
comma = FALSE;
s += langDBINF_TXN_ISOLATION_OPTS;
if (pDb->dbInf.txnIsolationOptions & SQL_TXN_READ_UNCOMMITTED)
if (pDb->dbInf.staticSensitivity & SQL_SS_UPDATES)
{if (comma++) s += ", "; s += langDBINF_UPDATES;}
s += "\n";
+#ifdef __VMS__
+#pragma message enable incboodep
+#endif
s += langDBINF_TXN_CAPABLE;
} // DisplayDbDiagnostics()
+#if wxUSE_NEW_GRID
+
+BEGIN_EVENT_TABLE(DbGridFrame, wxFrame)
+ // EVT_CLOSE(DbGridFrame::OnCloseWindow)
+END_EVENT_TABLE()
+
+
+DbGridFrame::DbGridFrame(wxWindow *parent)
+ : wxFrame (parent, -1, wxT("Database Table"),
+ wxDefaultPosition, wxSize(400, 325))
+{
+ initialized = FALSE;
+}
+
+
+void DbGridFrame::OnCloseWindow(wxCloseEvent& event)
+{
+ this->Destroy();
+}
+bool DbGridFrame::Initialize()
+{
+ wxGrid *grid = new wxGrid(this, -1, wxDefaultPosition);
+
+ grid->RegisterDataType(wxGRID_VALUE_DATETIME,
+ new wxGridCellDateTimeRenderer(_T("%d %b %Y")),
+ new wxGridCellTextEditor);
+#ifdef CHOICEINT
+ grid->RegisterDataType(wxGRID_VALUE_CHOICEINT,
+ new wxGridCellEnumRenderer,
+ new wxGridCellEnumEditor);
+
+ wxString NativeLangChoice( wxString::Format("%s:%s,%s,%s,%s,%s",wxGRID_VALUE_CHOICEINT,
+ wxT("English"),
+ wxT("French"),
+ wxT("German"),
+ wxT("Spanish"),
+ wxT("Other") ));
+#endif
+
+ // Columns must match the sequence specified in SetColDef() calls
+ wxDbGridColInfo* cols =
+ new wxDbGridColInfo( 0,wxGRID_VALUE_STRING,wxT("Name"),
+ new wxDbGridColInfo( 1,wxGRID_VALUE_STRING,wxT("Address 1"),
+ new wxDbGridColInfo( 2,wxGRID_VALUE_STRING,wxT("Address 2"),
+ new wxDbGridColInfo( 3,wxGRID_VALUE_STRING,wxT("City"),
+ new wxDbGridColInfo( 4,wxGRID_VALUE_STRING,wxT("State"),
+ new wxDbGridColInfo( 5,wxGRID_VALUE_STRING,wxT("PostCode"),
+ new wxDbGridColInfo( 6,wxGRID_VALUE_STRING,wxT("Country"),
+ new wxDbGridColInfo( 7,wxGRID_VALUE_DBAUTO,wxT("Join Date"),
+ new wxDbGridColInfo( 8,wxGRID_VALUE_BOOL, wxT("Developer"),
+ new wxDbGridColInfo( 9,wxGRID_VALUE_NUMBER,wxT("Contributions"),
+ new wxDbGridColInfo(10,wxGRID_VALUE_NUMBER,wxT("Lines Of Code"),
+#ifdef CHOICEINT
+ new wxDbGridColInfo(11,NativeLangChoice, wxT("Native Language"),NULL))))))))))));
+#else
+ new wxDbGridColInfo(11,wxGRID_VALUE_NUMBER,wxT("Native Language"),NULL))))))))))));
+#endif
+
+ Ccontact *Contact = new Ccontact();
+ //wxGetApp().Contact
+
+ if (!Contact)
+ {
+ wxMessageBox(wxT("Unable to instantiate an instance of Ccontact"), wxT("Error..."), wxOK | wxICON_EXCLAMATION);
+ return FALSE;
+ }
+
+ if (!Contact->Open())
+ {
+ if (Contact->GetDb()->TableExists(CONTACT_TABLE_NAME, Contact->GetDb()->GetUsername(),
+ wxGetApp().DbConnectInf->GetDefaultDir()))
+ {
+ wxString tStr;
+ tStr.Printf(wxT("Unable to open the table '%s'.\n\n"),CONTACT_TABLE_NAME);
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+ }
+
+ return FALSE;
+ }
+
+ // Execute the following query using the cursor designated
+ // for full table query
+ Contact->SetRowMode(wxDbTable::WX_ROW_MODE_QUERY);
+
+ if (!Contact->Query())
+ {
+ wxString tStr;
+ tStr = wxT("ODBC error during Query()\n\n");
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+ return FALSE;
+ }
+
+ // No data has been read in from the database yet, so
+ // we need to initialize the data members to valid values
+ // so Fit() can correctly size the grid
+ Contact->Initialize();
+
+ wxDbGridTableBase* db = new wxDbGridTableBase(Contact, cols, wxUSE_QUERY, TRUE);
+
+ delete cols;
+
+ grid->SetTable(db,TRUE);
+ grid->SetMargins(0, 0);
+
+ grid->Fit();
+ wxSize size = grid->GetSize();
+ size.x += 10;
+ size.y += 10;
+ SetClientSize(size);
+ initialized = TRUE;
+ return TRUE;
+} // DbGridFrame::Initialize()
+
+#endif // #if wxUSE_NEW_GRID
/*
TEST CODE FOR TESTING THE wxDbCreateDataSource() FUNCTION