+#ifdef wxODBC_BLOB_SUPPORT
+
+BEGIN_EVENT_TABLE(CimageDlg, wxDialog)
+ EVT_CLOSE(CimageDlg::OnCloseWindow)
+END_EVENT_TABLE()
+
+CimageDlg::CimageDlg(wxWindow *parent, wxChar *pImageData, off_t iSize)
+: wxDialog(parent, IMAGE_DIALOG, wxT("BLOB Image"), wxDefaultPosition, wxDefaultSize),
+m_pDisplayBmp(NULL),
+m_pBmp(NULL),
+m_pImage(NULL)
+{
+ wxMemoryInputStream inStream(pImageData, iSize);
+
+ if(inStream.IsOk())
+ {
+ m_pImage = new wxImage(inStream, wxBITMAP_TYPE_ANY);
+
+ if(m_pImage->Ok())
+ {
+ m_pBmp = new wxBitmap(*m_pImage);
+ m_pDisplayBmp = new wxStaticBitmap(this, IMAGE_DIALOG_STATIC_BMP, *m_pBmp, wxPoint(5,5), wxDefaultSize);
+
+ SetSize(m_pBmp->GetWidth() + 10, m_pBmp->GetHeight() + 30);
+ }
+ }
+}
+
+CimageDlg::~CimageDlg()
+{
+ if(m_pImage)
+ delete m_pImage;
+
+ if(m_pBmp)
+ delete m_pBmp;
+
+ if(m_pDisplayBmp)
+ delete m_pDisplayBmp;
+}
+
+void CimageDlg::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
+{
+ GetParent()->SetFocus();
+
+ Show(false);
+
+ this->Destroy();
+}
+
+#endif
+
+void DisplayDbDiagnostics(wxDb *pDb)
+{
+ wxString s, t;
+ bool comma;
+
+ s = wxT("Diagnostics Output\n");
+ s += langDBINF_DB_NAME;
+ s += pDb->dbInf.dbmsName;
+ s += wxT("\n");
+
+ s += langDBINF_DB_VER;
+ s += pDb->dbInf.dbmsVer;
+ s += wxT("\n");
+
+ s += langDBINF_DRIVER_NAME;
+ s += pDb->dbInf.driverName;
+ s += wxT("\n");
+
+ s += langDBINF_DRIVER_ODBC_VER;
+ s += pDb->dbInf.odbcVer;
+ s += wxT("\n");
+
+ s += langDBINF_DRIVER_MGR_ODBC_VER;
+ s += pDb->dbInf.drvMgrOdbcVer;
+ s += wxT("\n");
+
+ s += langDBINF_DRIVER_VER;
+ s += pDb->dbInf.driverVer;
+ s += wxT("\n");
+
+ s += langDBINF_SERVER_NAME;
+ s += pDb->dbInf.serverName;
+ s += wxT("\n");
+
+ s += langDBINF_FILENAME;
+ s += pDb->dbInf.databaseName;
+ s += wxT("\n");
+
+ s += langDBINF_OUTER_JOINS;
+ s += pDb->dbInf.outerJoins;
+ s += wxT("\n");
+
+ s += langDBINF_STORED_PROC;
+ s += pDb->dbInf.procedureSupport;
+ s += wxT("\n");
+
+ if (pDb->dbInf.maxConnections)
+ t.sprintf(wxT("%s%d\n"), langDBINF_MAX_HDBC, pDb->dbInf.maxConnections);
+ else
+ t.sprintf(wxT("%s%s\n"), langDBINF_MAX_HDBC, langDBINF_UNLIMITED);
+ s += t;
+
+ if (pDb->dbInf.maxStmts)
+ t.sprintf(wxT("%s%d\n"), langDBINF_MAX_HSTMT, pDb->dbInf.maxStmts);
+ else
+ t.sprintf(wxT("%s%s\n"), langDBINF_MAX_HSTMT, langDBINF_UNLIMITED);
+ s += t;
+
+ s += langDBINF_API_LVL;
+ switch(pDb->dbInf.apiConfLvl)
+ {
+ case SQL_OAC_NONE: s += langDBINF_NONE; break;
+ case SQL_OAC_LEVEL1: s += langDBINF_LEVEL1; break;
+ case SQL_OAC_LEVEL2: s += langDBINF_LEVEL2; break;
+ }
+ s += wxT("\n");
+
+ s += langDBINF_CLI_LVL;
+ switch(pDb->dbInf.cliConfLvl)
+ {
+ case SQL_OSCC_NOT_COMPLIANT: s += langDBINF_NOT_COMPLIANT; break;
+ case SQL_OSCC_COMPLIANT: s += langDBINF_COMPLIANT; break;
+ }
+ s += wxT("\n");
+
+ s += langDBINF_SQL_LVL;
+ switch(pDb->dbInf.sqlConfLvl)
+ {
+ case SQL_OSC_MINIMUM: s += langDBINF_MIN_GRAMMAR; break;
+ case SQL_OSC_CORE: s += langDBINF_CORE_GRAMMAR; break;
+ case SQL_OSC_EXTENDED: s += langDBINF_EXT_GRAMMAR; break;
+ }
+ s += wxT("\n");
+
+ s += langDBINF_COMMIT_BEHAVIOR;
+ switch(pDb->dbInf.cursorCommitBehavior)
+ {
+ case SQL_CB_DELETE: s += langDBINF_DELETE_CURSORS; break;
+ case SQL_CB_CLOSE: s += langDBINF_CLOSE_CURSORS; break;
+ case SQL_CB_PRESERVE: s += langDBINF_PRESERVE_CURSORS; break;
+ }
+ s += wxT("\n");
+
+ s += langDBINF_ROLLBACK_BEHAVIOR;
+ switch(pDb->dbInf.cursorRollbackBehavior)
+ {
+ case SQL_CB_DELETE: s += langDBINF_DELETE_CURSORS; break;
+ case SQL_CB_CLOSE: s += langDBINF_CLOSE_CURSORS; break;
+ case SQL_CB_PRESERVE: s += langDBINF_PRESERVE_CURSORS; break;
+ }
+ s += wxT("\n");
+
+ s += langDBINF_SUPP_NOT_NULL;
+ switch(pDb->dbInf.supportNotNullClause)
+ {
+ case SQL_NNC_NULL: s += langNO; break;
+ case SQL_NNC_NON_NULL: s += langYES; break;
+ }
+ s += wxT("\n");
+
+ s += langDBINF_SUPP_IEF;
+ s += pDb->dbInf.supportIEF;
+ s += wxT("\n");
+
+ // DEFAULT setting for "Transaction Isolation Level"
+ s += langDBINF_TXN_ISOLATION;
+ switch(pDb->dbInf.txnIsolation)
+ {
+ case SQL_TXN_READ_UNCOMMITTED: s += langDBINF_READ_UNCOMMITTED; break;
+ case SQL_TXN_READ_COMMITTED: s += langDBINF_READ_COMMITTED; break;
+ case SQL_TXN_REPEATABLE_READ: s += langDBINF_REPEATABLE_READ; break;
+ case SQL_TXN_SERIALIZABLE: s += langDBINF_SERIALIZABLE; break;
+#ifdef ODBC_V20
+ case SQL_TXN_VERSIONING: s += langDBINF_VERSIONING; break;
+#endif
+ }
+ s += wxT("\n");
+
+ // CURRENT setting for "Transaction Isolation Level"
+ long txnIsoLvl;
+ s += langDBINF_TXN_ISOLATION_CURR;
+ if (SQLGetConnectOption(pDb->GetHDBC(),SQL_TXN_ISOLATION,&txnIsoLvl) == SQL_SUCCESS)
+ {
+ switch(txnIsoLvl)
+ {
+ case SQL_TXN_READ_UNCOMMITTED: s += langDBINF_READ_UNCOMMITTED; break;
+ case SQL_TXN_READ_COMMITTED: s += langDBINF_READ_COMMITTED; break;
+ case SQL_TXN_REPEATABLE_READ: s += langDBINF_REPEATABLE_READ; break;
+ case SQL_TXN_SERIALIZABLE: s += langDBINF_SERIALIZABLE; break;
+#ifdef ODBC_V20
+ case SQL_TXN_VERSIONING: s += langDBINF_VERSIONING; break;
+#endif
+ }
+ }
+ s += wxT("\n");
+
+#ifdef __VMS__
+#pragma message disable incboodep
+#endif
+ comma = false;
+ s += langDBINF_TXN_ISOLATION_OPTS;
+ if (pDb->dbInf.txnIsolationOptions & SQL_TXN_READ_UNCOMMITTED)
+ {s += langDBINF_READ_UNCOMMITTED; comma++;}
+ if (pDb->dbInf.txnIsolationOptions & SQL_TXN_READ_COMMITTED)
+ {if (comma++) s += wxT(", "); s += langDBINF_READ_COMMITTED;}
+ if (pDb->dbInf.txnIsolationOptions & SQL_TXN_REPEATABLE_READ)
+ {if (comma++) s += wxT(", "); s += langDBINF_REPEATABLE_READ;}
+ if (pDb->dbInf.txnIsolationOptions & SQL_TXN_SERIALIZABLE)
+ {if (comma++) s += wxT(", "); s += langDBINF_SERIALIZABLE;}
+#ifdef ODBC_V20
+ if (pDb->dbInf.txnIsolationOptions & SQL_TXN_VERSIONING)
+ {if (comma++) s += wxT(", "); s += langDBINF_VERSIONING;}
+#endif
+ s += wxT("\n");
+
+ comma = false;
+ s += langDBINF_FETCH_DIRS;
+ if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_NEXT)
+ {s += langDBINF_NEXT; comma++;}
+ if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_PRIOR)
+ {if (comma++) s += wxT(", "); s += langDBINF_PREV;}
+ if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_FIRST)
+ {if (comma++) s += wxT(", "); s += langDBINF_FIRST;}
+ if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_LAST)
+ {if (comma++) s += wxT(", "); s += langDBINF_LAST;}
+ if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_ABSOLUTE)
+ {if (comma++) s += wxT(", "); s += langDBINF_ABSOLUTE;}
+ if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_RELATIVE)
+ {if (comma++) s += wxT(", "); s += langDBINF_RELATIVE;}
+#ifdef ODBC_V20
+ if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_RESUME)
+ {if (comma++) s += wxT(", "); s += langDBINF_RESUME;}
+#endif
+ if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_BOOKMARK)
+ {if (comma++) s += wxT(", "); s += langDBINF_BOOKMARK;}
+ s += wxT("\n");
+
+ comma = false;
+ s += langDBINF_LOCK_TYPES;
+ if (pDb->dbInf.lockTypes & SQL_LCK_NO_CHANGE)
+ {s += langDBINF_NO_CHANGE; comma++;}
+ if (pDb->dbInf.lockTypes & SQL_LCK_EXCLUSIVE)
+ {if (comma++) s += wxT(", "); s += langDBINF_EXCLUSIVE;}
+ if (pDb->dbInf.lockTypes & SQL_LCK_UNLOCK)
+ {if (comma++) s += wxT(", "); s += langDBINF_UNLOCK;}
+ s += wxT("\n");
+
+ comma = false;
+ s += langDBINF_POS_OPERS;
+ if (pDb->dbInf.posOperations & SQL_POS_POSITION)
+ {s += langDBINF_POSITION; comma++;}
+ if (pDb->dbInf.posOperations & SQL_POS_REFRESH)
+ {if (comma++) s += wxT(", "); s += langDBINF_REFRESH;}
+ if (pDb->dbInf.posOperations & SQL_POS_UPDATE)
+ {if (comma++) s += wxT(", "); s += langDBINF_UPD;}
+ if (pDb->dbInf.posOperations & SQL_POS_DELETE)
+ {if (comma++) s += wxT(", "); s += langDBINF_DEL;}
+ if (pDb->dbInf.posOperations & SQL_POS_ADD)
+ {if (comma++) s += wxT(", "); s += langDBINF_ADD;}
+ s += wxT("\n");
+
+ comma = false;
+ s += langDBINF_POS_STMTS;
+ if (pDb->dbInf.posStmts & SQL_PS_POSITIONED_DELETE)
+ {s += langDBINF_POS_DEL; comma++;}
+ if (pDb->dbInf.posStmts & SQL_PS_POSITIONED_UPDATE)
+ {if (comma++) s += wxT(", "); s += langDBINF_POS_UPD;}
+ if (pDb->dbInf.posStmts & SQL_PS_SELECT_FOR_UPDATE)
+ {if (comma++) s += wxT(", "); s += langDBINF_SELECT_FOR_UPD;}
+ s += wxT("\n");
+
+ comma = false;
+ s += langDBINF_SCROLL_CONCURR;
+ if (pDb->dbInf.scrollConcurrency & SQL_SCCO_READ_ONLY)
+ {s += langDBINF_READ_ONLY; comma++;}
+ if (pDb->dbInf.scrollConcurrency & SQL_SCCO_LOCK)
+ {if (comma++) s += wxT(", "); s += langDBINF_LOCK;}
+ if (pDb->dbInf.scrollConcurrency & SQL_SCCO_OPT_ROWVER)
+ {if (comma++) s += wxT(", "); s += langDBINF_OPT_ROWVER;}
+ if (pDb->dbInf.scrollConcurrency & SQL_SCCO_OPT_VALUES)
+ {if (comma++) s += wxT(", "); s += langDBINF_OPT_VALUES;}
+ s += wxT("\n");
+
+ comma = false;
+ s += langDBINF_SCROLL_OPTS;
+ if (pDb->dbInf.scrollOptions & SQL_SO_FORWARD_ONLY)
+ {s += langDBINF_FWD_ONLY; comma++;}
+ if (pDb->dbInf.scrollOptions & SQL_SO_STATIC)
+ {if (comma++) s += wxT(", "); s += langDBINF_STATIC;}
+ if (pDb->dbInf.scrollOptions & SQL_SO_KEYSET_DRIVEN)
+ {if (comma++) s += wxT(", "); s += langDBINF_KEYSET_DRIVEN;}
+ if (pDb->dbInf.scrollOptions & SQL_SO_DYNAMIC)
+ {if (comma++) s += wxT(", "); s += langDBINF_DYNAMIC;}
+ if (pDb->dbInf.scrollOptions & SQL_SO_MIXED)
+ {if (comma++) s += wxT(", "); s += langDBINF_MIXED;}
+ s += wxT("\n");
+
+ comma = false;
+ s += langDBINF_STATIC_SENS;
+ if (pDb->dbInf.staticSensitivity & SQL_SS_ADDITIONS)
+ {s += langDBINF_ADDITIONS; comma++;}
+ if (pDb->dbInf.staticSensitivity & SQL_SS_DELETIONS)
+ {if (comma++) s += wxT(", "); s += langDBINF_DELETIONS;}
+ if (pDb->dbInf.staticSensitivity & SQL_SS_UPDATES)
+ {if (comma++) s += wxT(", "); s += langDBINF_UPDATES;}
+ s += wxT("\n");
+#ifdef __VMS__
+#pragma message enable incboodep
+#endif
+
+
+ s += langDBINF_TXN_CAPABLE;
+ switch(pDb->dbInf.txnCapable)
+ {
+ case SQL_TC_NONE: s += langNO; break;
+ case SQL_TC_DML: s += langDBINF_DML_ONLY; break;
+ case SQL_TC_DDL_COMMIT: s += langDBINF_DDL_COMMIT; break;
+ case SQL_TC_DDL_IGNORE: s += langDBINF_DDL_IGNORE; break;
+ case SQL_TC_ALL: s += langDBINF_DDL_AND_DML; break;
+ }
+ s += wxT("\n");
+
+ t.sprintf(wxT("%s%lu\n"), langDBINF_LOGIN_TIMEOUT, pDb->dbInf.loginTimeout);
+ s += t;
+
+ // Oracle specific information
+ if (pDb->Dbms() == dbmsORACLE)
+ {
+ s += wxT("\n");
+ s += langDBINF_ORACLE_BANNER;
+ s += wxT("\n");
+
+ // Oracle cache hit ratio
+ SDWORD cb;
+ ULONG dbBlockGets;
+ pDb->ExecSql(wxT("SELECT VALUE FROM V$SYSSTAT WHERE NAME = 'db block gets'"));
+ pDb->GetNext();
+ if (pDb->GetData(1, SQL_C_ULONG, &dbBlockGets, 0, &cb))
+ {
+ t.sprintf(wxT("%s: %lu\n"), langDBINF_DB_BLOCK_GETS, dbBlockGets);
+ s += t;
+ }
+
+ ULONG consistentGets;
+ pDb->ExecSql(wxT("SELECT VALUE FROM V$SYSSTAT WHERE NAME = 'consistent gets'"));
+ pDb->GetNext();
+ if (pDb->GetData(1, SQL_C_ULONG, &consistentGets, 0, &cb))
+ {
+ t.sprintf(wxT("%s: %lu\n"), langDBINF_CONSISTENT_GETS, consistentGets);
+ s += t;
+ }
+
+ ULONG physReads;
+ pDb->ExecSql(wxT("SELECT VALUE FROM V$SYSSTAT WHERE NAME = 'physical reads'"));
+ pDb->GetNext();
+ if (pDb->GetData(1, SQL_C_ULONG, &physReads, 0, &cb))
+ {
+ t.sprintf(wxT("%s: %lu\n"), langDBINF_PHYSICAL_READS, physReads);
+ s += t;
+ }
+
+ ULONG hitRatio = (ULONG)((1.00 - ((float)physReads / (float)(dbBlockGets + consistentGets))) * 100.00);
+ t.sprintf(wxT("*** %s: %lu%%\n"), langDBINF_CACHE_HIT_RATIO, hitRatio);
+ s += t;
+
+ // Tablespace information
+ s += wxT("\n");
+ s += langDBINF_TABLESPACE_IO;
+ s += wxT("\n");
+ ULONG physWrites;
+ char tablespaceName[256+1];
+ pDb->ExecSql(wxT("SELECT NAME,PHYRDS,PHYWRTS FROM V$DATAFILE, V$FILESTAT WHERE V$DATAFILE.FILE# = V$FILESTAT.FILE#"));
+ while (pDb->GetNext())
+ {
+ pDb->GetData(1, SQL_C_WXCHAR, tablespaceName, 256, &cb);
+ pDb->GetData(2, SQL_C_ULONG, &physReads, 0, &cb);
+ pDb->GetData(3, SQL_C_ULONG, &physWrites, 0, &cb);
+ t.sprintf(wxT("%s\n\t%s: %lu\t%s: %lu\n"), tablespaceName,
+ langDBINF_PHYSICAL_READS, physReads, langDBINF_PHYSICAL_WRITES, physWrites);
+ s += t;
+ }
+
+ s += wxT("\n");
+ }
+
+ s += wxT("End of Diagnostics\n");
+ wxLogMessage(s);
+
+} // DisplayDbDiagnostics()
+
+#if wxUSE_GRID
+
+BEGIN_EVENT_TABLE(DbGridFrame, wxFrame)
+ // EVT_CLOSE(DbGridFrame::OnCloseWindow)
+END_EVENT_TABLE()
+
+
+DbGridFrame::DbGridFrame(wxWindow *parent)
+ : wxFrame (parent, wxID_ANY, wxT("Database Table"),
+ wxDefaultPosition, wxSize(400, 325))
+{
+ initialized = false;
+}
+
+
+void DbGridFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
+{
+ this->Destroy();
+}
+
+
+bool DbGridFrame::Initialize()
+{
+ wxGrid *grid = new wxGrid(this, wxID_ANY, wxDefaultPosition);
+
+ grid->RegisterDataType(wxGRID_VALUE_DATETIME,
+ new wxGridCellDateTimeRenderer(wxT("%d %b %Y")),
+ new wxGridCellTextEditor);
+#ifdef CHOICEINT
+ grid->RegisterDataType(wxGRID_VALUE_CHOICEINT,
+ new wxGridCellEnumRenderer,
+ new wxGridCellEnumEditor);
+
+ wxString NativeLangChoice( wxString::Format(wxT("%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.c_str());
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__TFILE__,__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(),__TFILE__,__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);