-/*
- * This function will return the exact string(s) from the database engine
- * indicating all error conditions which have just occured during the
- * last call to the database engine.
- *
- * This demo uses the returned string by displaying it in a wxMessageBox. The
- * formatting therefore is not the greatest, but this is just a demo, not a
- * finished product. :-) gt
- *
- * NOTE: The value returned by this function is for temporary use only and
- * should be copied for long term use
- */
-char *GetExtendedDBErrorMsg(char *ErrFile, int ErrLine)
-{
- static wxString msg;
-
- wxString tStr;
-
- if (ErrFile || ErrLine)
- {
- msg += "\n";
- msg.Append ('-',80);
- msg += "\nFile: ";
- msg += ErrFile;
- msg += " Line: ";
- tStr.sprintf("%d",ErrLine);
- msg += tStr.GetData();
- msg += "\n";
- }
-
- msg.Append ('-',80);
- msg.Append ("\nODBC ERRORS\n");
- msg.Append ('-',80);
- msg += "\n";
- // Scan through each database connection displaying
- // any ODBC errors that have occured.
- for (DbList *pDbList = PtrBegDbList; pDbList; pDbList = pDbList->PtrNext)
- {
- // Skip over any free connections
- if (pDbList->Free)
- continue;
- // Display errors for this connection
- for (int i = 0; i < DB_MAX_ERROR_HISTORY; i++)
- {
- if (pDbList->PtrDb->errorList[i])
- {
- msg.Append(pDbList->PtrDb->errorList[i]);
- if (strcmp(pDbList->PtrDb->errorList[i],"") != 0)
- msg.Append("\n");
- }
- }
- }
- msg += "\n";
-
- return msg.GetData();
-} // GetExtendedDBErrorMsg
-
-
-
-// `Main program' equivalent, creating windows and returning main app frame
-wxFrame *DatabaseDemoApp::OnInit(void)
-{
- // Create the main frame window
- DemoFrame = new DatabaseDemoFrame(NULL, "wxWindows Database Demo", 50, 50, 537, 480);
-
- // Give it an icon
-#ifdef __WXMSW__
- DemoFrame->SetIcon(wxIcon("db_icon"));
-#endif
-#ifdef __X__
- DemoFrame->SetIcon(wxIcon("db.xbm"));
-#endif
-
- // Make a menubar
- wxMenu *file_menu = new wxMenu;
- file_menu->Append(FILE_CREATE, "&Create contact table");
- file_menu->Append(FILE_EXIT, "E&xit");
-
- wxMenu *edit_menu = new wxMenu;
- edit_menu->Append(EDIT_PARAMETERS, "&Parameters...");
-
- wxMenu *about_menu = new wxMenu;
- about_menu->Append(ABOUT_DEMO, "&About");
-
- wxMenuBar *menu_bar = new wxMenuBar;
- menu_bar->Append(file_menu, "&File");
- menu_bar->Append(edit_menu, "&Edit");
- menu_bar->Append(about_menu, "&About");
- DemoFrame->SetMenuBar(menu_bar);
-
- // Initialize the ODBC Environment for Database Operations
- if (SQLAllocEnv(&DbConnectInf.Henv) != SQL_SUCCESS)
- {
- wxMessageBox("A problem occured while trying to get a connection to the data source","DB CONNECTION ERROR",wxOK | wxICON_EXCLAMATION);
- return NULL;
- }
-
- FILE *paramFile;
- if ((paramFile = fopen(paramFilename, "r")) == NULL)
- {
- wxString tStr;
- tStr.sprintf("Unable to open the parameter file '%s' for reading.\n\nYou must specify the data source, user name, and\npassword that will be used and save those settings.",paramFilename);
- wxMessageBox(tStr.GetData(),"File I/O Error...",wxOK | wxICON_EXCLAMATION);
- DemoFrame->BuildParameterDialog(NULL);
- if ((paramFile = fopen(paramFilename, "r")) == NULL)
- return FALSE;
- }
-
- char buffer[1000+1];
- fgets(buffer, sizeof(params.ODBCSource), paramFile);
- buffer[strlen(buffer)-1] = '\0';
- strcpy(params.ODBCSource,buffer);
-
- fgets(buffer, sizeof(params.UserName), paramFile);
- buffer[strlen(buffer)-1] = '\0';
- strcpy(params.UserName,buffer);
-
- fgets(buffer, sizeof(params.Password), paramFile);
- buffer[strlen(buffer)-1] = '\0';
- strcpy(params.Password,buffer);
-
- fclose(paramFile);
-
- // Connect to datasource
- strcpy(DbConnectInf.Dsn, params.ODBCSource); // ODBC data source name (created with ODBC Administrator under Win95/NT)
- strcpy(DbConnectInf.Uid, params.UserName); // database username - must already exist in the data source
- strcpy(DbConnectInf.AuthStr, params.Password); // password database username
- READONLY_DB = GetDbConnection(&DbConnectInf);
- if (READONLY_DB == 0)
- {
- wxMessageBox("Unable to connect to the data source.\n\nCheck the name of your data source to verify it has been correctly entered/spelled.\n\nWith some databases, the user name and password must\nbe created with full rights to the CONTACT table prior to making a connection\n(using tools provided by the database manufacturer)", "DB CONNECTION ERROR...",wxOK | wxICON_EXCLAMATION);
- DemoFrame->BuildParameterDialog(NULL);
- strcpy(DbConnectInf.Dsn, "");
- strcpy(DbConnectInf.Uid, "");
- strcpy(DbConnectInf.AuthStr, "");
- wxMessageBox("Now exiting program.\n\nRestart program to try any new settings.","Notice...",wxOK | wxICON_INFORMATION);
- return(FALSE);
- }
-
- DemoFrame->BuildEditorDialog();
-
- // Show the frame
- DemoFrame->Show(TRUE);
-
- // Return the main frame window
- return DemoFrame;
+
+void CheckSupportForAllDataTypes(wxDb *pDb)
+{
+ wxString nativeDataTypeName;
+
+ wxLogMessage(wxT("\nThe following datatypes are supported by the\ndatabase you are currently connected to:"));
+#ifdef SQL_C_BINARY
+ if (DataTypeSupported(pDb,SQL_C_BINARY, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_BINARY (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_BIT
+ if (DataTypeSupported(pDb,SQL_C_BIT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_BIT (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_BOOKMARK
+ if (DataTypeSupported(pDb,SQL_C_BOOKMARK, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_BOOKMARK (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_CHAR
+ if (DataTypeSupported(pDb,SQL_C_CHAR, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_CHAR (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_DATE
+ if (DataTypeSupported(pDb,SQL_C_DATE, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_DATE (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_DEFAULT
+ if (DataTypeSupported(pDb,SQL_C_DEFAULT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_DEFAULT (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_DOUBLE
+ if (DataTypeSupported(pDb,SQL_C_DOUBLE, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_DOUBLE (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_FLOAT
+ if (DataTypeSupported(pDb,SQL_C_FLOAT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_FLOAT (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_GUID
+ if (DataTypeSupported(pDb,SQL_C_GUID, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_GUID (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_INTERVAL_DAY
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_DAY, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_INTERVAL_DAY (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_INTERVAL_DAY_TO_HOUR
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_DAY_TO_HOUR, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_INTERVAL_DAY_TO_HOUR (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_INTERVAL_DAY_TO_MINUTE
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_DAY_TO_MINUTE, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_INTERVAL_DAY_TO_MINUTE (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_INTERVAL_DAY_TO_SECOND
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_DAY_TO_SECOND, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_INTERVAL_DAY_TO_SECOND (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_INTERVAL_HOUR
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_HOUR, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_INTERVAL_HOUR (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_INTERVAL_HOUR_TO_MINUTE
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_HOUR_TO_MINUTE, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_INTERVAL_HOUR_TO_MINUTE (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_INTERVAL_HOUR_TO_SECOND
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_HOUR_TO_SECOND, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_INTERVAL_HOUR_TO_SECOND (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_INTERVAL_MINUTE
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_MINUTE, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_INTERVAL_MINUTE (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_INTERVAL_MINUTE_TO_SECOND
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_MINUTE_TO_SECOND, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_INTERVAL_MINUTE_TO_SECOND (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_INTERVAL_MONTH
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_MONTH, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_INTERVAL_MONTH (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_INTERVAL_SECOND
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_SECOND, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_INTERVAL_SECOND (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_INTERVAL_YEAR
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_YEAR, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_INTERVAL_YEAR (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_INTERVAL_YEAR_TO_MONTH
+ if (DataTypeSupported(pDb,SQL_C_INTERVAL_YEAR_TO_MONTH, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_INTERVAL_YEAR_TO_MONTH (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_LONG
+ if (DataTypeSupported(pDb,SQL_C_LONG, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_LONG (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_NUMERIC
+ if (DataTypeSupported(pDb,SQL_C_NUMERIC, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_NUMERIC (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_SBIGINT
+ if (DataTypeSupported(pDb,SQL_C_SBIGINT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_SBIGINT (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_SHORT
+ if (DataTypeSupported(pDb,SQL_C_SHORT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_SHORT (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_SLONG
+ if (DataTypeSupported(pDb,SQL_C_SLONG, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_SLONG (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_SSHORT
+ if (DataTypeSupported(pDb,SQL_C_SSHORT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_SSHORT (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_STINYINT
+ if (DataTypeSupported(pDb,SQL_C_STINYINT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_STINYINT (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_TIME
+ if (DataTypeSupported(pDb,SQL_C_TIME, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_TIME (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_TIMESTAMP
+ if (DataTypeSupported(pDb,SQL_C_TIMESTAMP, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_TIMESTAMP (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_TINYINT
+ if (DataTypeSupported(pDb,SQL_C_TINYINT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_TINYINT (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_TYPE_DATE
+ if (DataTypeSupported(pDb,SQL_C_TYPE_DATE, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_TYPE_DATE (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_TYPE_TIME
+ if (DataTypeSupported(pDb,SQL_C_TYPE_TIME, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_TYPE_TIME (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_TYPE_TIMESTAMP
+ if (DataTypeSupported(pDb,SQL_C_TYPE_TIMESTAMP, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_TYPE_TIMESTAMP (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_UBIGINT
+ if (DataTypeSupported(pDb,SQL_C_UBIGINT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_UBIGINT (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_ULONG
+ if (DataTypeSupported(pDb,SQL_C_ULONG, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_ULONG (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_USHORT
+ if (DataTypeSupported(pDb,SQL_C_USHORT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_USHORT (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_UTINYINT
+ if (DataTypeSupported(pDb,SQL_C_UTINYINT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_UTINYINT (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_VARBOOKMARK
+ if (DataTypeSupported(pDb,SQL_C_VARBOOKMARK, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_VARBOOKMARK (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_C_WXCHAR
+ if (DataTypeSupported(pDb,SQL_C_WXCHAR, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_WXCHAR (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+
+// Extended SQL types
+#ifdef SQL_DATE
+ if (DataTypeSupported(pDb,SQL_DATE, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_DATE (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_INTERVAL
+ if (DataTypeSupported(pDb,SQL_INTERVAL, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_INTERVAL (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_TIME
+ if (DataTypeSupported(pDb,SQL_TIME, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_TIME (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_TIMESTAMP
+ if (DataTypeSupported(pDb,SQL_TIMESTAMP, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_TIMESTAMP (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_LONGVARCHAR
+ if (DataTypeSupported(pDb,SQL_LONGVARCHAR, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_LONGVARCHAR (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_BINARY
+ if (DataTypeSupported(pDb,SQL_BINARY, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_BINARY (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_VARBINARY
+ if (DataTypeSupported(pDb,SQL_VARBINARY, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_VARBINARY (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_LONGVARBINARY
+ if (DataTypeSupported(pDb,SQL_LONGVARBINARY, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_LOGVARBINARY (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_BIGINT
+ if (DataTypeSupported(pDb,SQL_BIGINT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_BIGINT (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_TINYINT
+ if (DataTypeSupported(pDb,SQL_TINYINT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_TINYINT (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_BIT
+ if (DataTypeSupported(pDb,SQL_BIT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_BIT (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_GUID
+ if (DataTypeSupported(pDb,SQL_GUID, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_GUID (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+
+#ifdef SQL_CHAR
+ if (DataTypeSupported(pDb,SQL_CHAR, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_CHAR (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_INTEGER
+ if (DataTypeSupported(pDb,SQL_INTEGER, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_INTEGER (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_SMALLINT
+ if (DataTypeSupported(pDb,SQL_SMALLINT, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_SAMLLINT (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_REAL
+ if (DataTypeSupported(pDb,SQL_REAL, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_REAL (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_DOUBLE
+ if (DataTypeSupported(pDb,SQL_DOUBLE, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_DOUBLE (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_NUMERIC
+ if (DataTypeSupported(pDb,SQL_NUMERIC, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_NUMERIC (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_DATE
+ if (DataTypeSupported(pDb,SQL_DATE, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_DATE (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_TIME
+ if (DataTypeSupported(pDb,SQL_TIME, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_TIME (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_TIMESTAMP
+ if (DataTypeSupported(pDb,SQL_TIMESTAMP, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_TIMESTAMP (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_VARCHAR
+ if (DataTypeSupported(pDb,SQL_VARCHAR, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_VARCHAR (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+
+// UNICODE
+#ifdef SQL_C_TCHAR
+ if (DataTypeSupported(pDb,SQL_C_TCHAR, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_C_TCHAR (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_WVARCHAR
+ if (DataTypeSupported(pDb,SQL_WVARCHAR, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_WVARCHAR (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+#ifdef SQL_WCHAR
+ if (DataTypeSupported(pDb,SQL_WCHAR, &nativeDataTypeName))
+ {
+ nativeDataTypeName = wxT("SQL_WCHAR (") + nativeDataTypeName;
+ nativeDataTypeName += wxT(")\n");
+ wxLogMessage(nativeDataTypeName);
+ }
+#endif
+
+ wxLogMessage(wxT("Done\n"));
+} // CheckSupportForAllDataTypes()
+
+
+bool DatabaseDemoApp::OnInit()
+{
+ if ( !wxApp::OnInit() )
+ return false;
+
+ DbConnectInf = NULL;
+ Contact = NULL;
+
+ // Create the main frame window
+ DemoFrame = new DatabaseDemoFrame(NULL, wxT("wxWidgets Database Demo"), wxPoint(50, 50), wxSize(537, 530));
+
+ // Give it an icon
+ DemoFrame->SetIcon(wxICON(db));
+
+ // Make a menubar
+ wxMenu *file_menu = new wxMenu;
+ file_menu->Append(FILE_CREATE_ID, 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_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;
+ edit_menu->Append(EDIT_PARAMETERS, wxT("&Parameters..."));
+
+ wxMenu *help_menu = new wxMenu;
+ help_menu->Append(HELP_ABOUT, wxT("&About"));
+
+ wxMenuBar *menu_bar = new wxMenuBar;
+ menu_bar->Append(file_menu, wxT("&File"));
+ menu_bar->Append(edit_menu, wxT("&Edit"));
+ menu_bar->Append(help_menu, wxT("&Help"));
+ DemoFrame->SetMenuBar(menu_bar);
+
+ params.ODBCSource[0] = 0;
+ params.UserName[0] = 0;
+ params.Password[0] = 0;
+ params.DirPath[0] = 0;
+
+#ifdef wxODBC_BLOB_SUPPORT
+ wxInitAllImageHandlers();
+ wxImage::InitStandardHandlers();
+ wxBitmap::InitStandardHandlers();
+#endif
+
+ // Show the frame
+ DemoFrame->Show(true);
+
+ // Passing NULL for the SQL environment handle causes
+ // the wxDbConnectInf constructor to obtain a handle
+ // for you.
+ //
+ // WARNING: Be certain that you do not free this handle
+ // directly with SQLFreeEnv(). Use either the
+ // method ::FreeHenv() or delete the DbConnectInf.
+ DbConnectInf = new wxDbConnectInf(NULL, params.ODBCSource, params.UserName,
+ params.Password, params.DirPath);
+
+ if (!DbConnectInf || !DbConnectInf->GetHenv())
+ {
+ wxMessageBox(wxT("Unable to define data source connection info."), wxT("DB CONNECTION ERROR..."),wxOK | wxICON_EXCLAMATION);
+ wxDELETE(DbConnectInf);
+ }
+
+ if (!ReadParamFile(params))
+ DemoFrame->BuildParameterDialog(NULL);
+
+ if (!wxStrlen(params.ODBCSource))
+ {
+ wxDELETE(DbConnectInf);
+ return(false);
+ }
+
+ DbConnectInf->SetDsn(params.ODBCSource);
+ DbConnectInf->SetUserID(params.UserName);
+ DbConnectInf->SetPassword(params.Password);
+ DbConnectInf->SetDefaultDir(params.DirPath);
+
+ READONLY_DB = wxDbGetConnection(DbConnectInf);
+ if (READONLY_DB == 0)
+ {
+ wxMessageBox(wxT("Unable to connect to the data source.\n\nCheck the name of your data source to verify it has been correctly entered/spelled.\n\nWith some databases, the user name and password must\nbe created with full rights to the CONTACT table prior to making a connection\n(using tools provided by the database manufacturer)"), wxT("DB CONNECTION ERROR..."),wxOK | wxICON_EXCLAMATION);
+ DemoFrame->BuildParameterDialog(NULL);
+ wxDELETE(DbConnectInf);
+ wxMessageBox(wxT("Now exiting program.\n\nRestart program to try any new settings."),wxT("Notice..."),wxOK | wxICON_INFORMATION);
+ return(false);
+ }
+
+ DemoFrame->BuildEditorDialog();
+
+ // Show the frame
+ DemoFrame->Refresh();
+
+ return true;