X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5d59e67a7bcbe633410cd78afc91ba82271f1294..d9207cc82635a45b05d1c56868efa680dc2094be:/samples/db/dbtest.cpp diff --git a/samples/db/dbtest.cpp b/samples/db/dbtest.cpp index 89b4c14ffb..4c8037a85d 100644 --- a/samples/db/dbtest.cpp +++ b/samples/db/dbtest.cpp @@ -46,6 +46,14 @@ //extern wxDbList WXDLLEXPORT *PtrBegDbList; /* from db.cpp, used in getting back error results from db connections */ +#if wxUSE_NEW_GRID +#include +#include +#include + +#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 */ @@ -60,46 +68,6 @@ extern wxChar ListDB_Selection2[]; /* Used to return the second column value fo #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) { wxDbSqlTypeInfo sqlTypeInfo; @@ -396,6 +364,9 @@ bool DatabaseDemoApp::OnInit() 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; @@ -546,20 +517,22 @@ void DatabaseDemoApp::CreateDataTable(bool recreate) { 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 { - if (!Contact->CreateIndexes()) + if (!Contact->CreateIndexes(recreate)) { 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; } } @@ -575,6 +548,9 @@ BEGIN_EVENT_TABLE(DatabaseDemoFrame, wxFrame) 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) @@ -615,21 +591,35 @@ void DatabaseDemoFrame::OnRecreateTable(wxCommandEvent& event) void DatabaseDemoFrame::OnRecreateIndexes(wxCommandEvent& event) { - if (!wxGetApp().Contact->CreateIndexes()) + wxGetApp().Contact->GetDb()->RollbackTrans(); // Make sure the current cursor is in a known/stable state + + 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 + 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(); @@ -775,9 +765,10 @@ Ccontact::~Ccontact() 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 @@ -788,7 +779,7 @@ Ccontact::~Ccontact() * 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 @@ -801,7 +792,7 @@ void Ccontact::SetupColumns() 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 @@ -810,7 +801,7 @@ void Ccontact::SetupColumns() } // Ccontact::SetupColumns -bool Ccontact::CreateIndexes(void) +bool Ccontact::CreateIndexes(bool recreate) { // This index could easily be accomplished with an "orderBy" clause, // but is done to show how to construct a non-primary index. @@ -827,7 +818,7 @@ bool Ccontact::CreateIndexes(void) indexName = GetTableName(); indexName += "_IDX1"; - Ok = CreateIndex(indexName.c_str(), TRUE, 2, idxDef); + Ok = CreateIndex(indexName.c_str(), TRUE, 2, idxDef, recreate); return Ok; } // Ccontact::CreateIndexes() @@ -1031,9 +1022,10 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event) 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; } @@ -1100,9 +1092,10 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event) 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 @@ -1136,9 +1129,9 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event) 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()) @@ -1177,22 +1170,23 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event) if (widgetName == pDataTypesBtn->GetName()) { CheckSupportForAllDataTypes(wxGetApp().READONLY_DB); - + wxMessageBox("Support datatypes was dumped to stdout."); return; } // Data types Button if (widgetName == pDbDiagsBtn->GetName()) { -/* -strcpy(wxGetApp().Contact->Addr1,"12345678901234567890"); -//wxString sqlStmt = "UPDATE CONTACTS set ADDRESS1='1234567890ABCEFG' where NAME='12345'"; -//if (wxGetApp().Contact->GetDb()->ExecSql(sqlStmt)) -if (wxGetApp().Contact->UpdateWhere("NAME = '12345'")) -wxGetApp().Contact->GetDb()->CommitTrans(); -else -wxGetApp().Contact->GetDb()->RollbackTrans(); -*/ DisplayDbDiagnostics(wxGetApp().READONLY_DB); + wxMessageBox("Diagnostics info was dumped to stdout."); + return; + } + + if (widgetName == pCatalogBtn->GetName()) + { + if (wxGetApp().Contact->GetDb()->Catalog("","catalog.txt")) + wxMessageBox("The file 'catalog.txt' was created."); + else + wxMessageBox("Creation of the file 'catalog.txt' was failed."); return; } @@ -1219,11 +1213,8 @@ bool CeditorDlg::Initialize() 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) { @@ -1247,13 +1238,14 @@ bool CeditorDlg::Initialize() // open the table. if (!wxGetApp().Contact->GetDb()->TablePrivileges(CONTACT_TABLE_NAME, wxT("SELECT"), wxGetApp().Contact->GetDb()->GetUsername(), - wxGetApp().Contact->GetDb()->GetUsername(), - wxGetApp().DbConnectInf->GetDefaultDir())) + wxGetApp().Contact->GetDb()->GetUsername(), + wxGetApp().DbConnectInf->GetDefaultDir())) { 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 @@ -1263,8 +1255,8 @@ bool CeditorDlg::Initialize() { 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; @@ -1322,6 +1314,7 @@ bool CeditorDlg::Initialize() pLinesMsg = new wxStaticText(this, EDITOR_DIALOG_LINES_MSG, wxT("Lines of code:"), wxPoint(303, 380), wxSize( -1, -1), 0, wxT("LinesMsg")); pLinesTxt = new wxTextCtrl(this, EDITOR_DIALOG_LINES_TEXT, wxT(""), wxPoint(303, 397), wxSize(100, 25), 0, wxDefaultValidator, wxT("LinesTxt")); + pCatalogBtn = new wxButton(this, EDITOR_DIALOG_CATALOG, wxT("Catalo&g"), wxPoint(430, 287), wxSize( 70, 35), 0, wxDefaultValidator, wxT("CatalogBtn")); pDataTypesBtn = new wxButton(this, EDITOR_DIALOG_DATATYPES, wxT("Data&types"), wxPoint(430, 337), wxSize( 70, 35), 0, wxDefaultValidator, wxT("DataTypesBtn")); pDbDiagsBtn = new wxButton(this, EDITOR_DIALOG_DB_DIAGS, wxT("DB Dia&gs"), wxPoint(430, 387), wxSize( 70, 35), 0, wxDefaultValidator, wxT("DbDiagsBtn")); @@ -1360,9 +1353,9 @@ bool CeditorDlg::Initialize() 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; } @@ -1612,17 +1605,17 @@ bool CeditorDlg::Save() 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); } } } @@ -1633,9 +1626,9 @@ bool CeditorDlg::Save() 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; } } @@ -1740,9 +1733,9 @@ bool CeditorDlg::GetRec(const wxString &whereStr) 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); } @@ -2050,9 +2043,9 @@ CqueryDlg::CqueryDlg(wxWindow *parent, wxDb *pDb, wxChar *tblName[], { 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; } @@ -2453,9 +2446,9 @@ void CqueryDlg::ProcessCountBtn() 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; } } @@ -2515,338 +2508,454 @@ bool CqueryDlg::ValidateWhereClause() void DisplayDbDiagnostics(wxDb *pDb) { - wxString s, t; - bool comma = FALSE; - - s = langDBINF_DB_NAME; - s += pDb->dbInf.dbmsName; - s += "\n"; - - s += langDBINF_DB_VER; - s += pDb->dbInf.dbmsVer; - s += "\n"; - - s += langDBINF_DRIVER_NAME; - s += pDb->dbInf.driverName; - s += "\n"; - - s += langDBINF_DRIVER_ODBC_VER; - s += pDb->dbInf.odbcVer; - s += "\n"; - - s += langDBINF_DRIVER_MGR_ODBC_VER; - s += pDb->dbInf.drvMgrOdbcVer; - s += "\n"; - - s += langDBINF_DRIVER_VER; - s += pDb->dbInf.driverVer; - s += "\n"; - - s += langDBINF_SERVER_NAME; - s += pDb->dbInf.serverName; - s += "\n"; - - s += langDBINF_FILENAME; - s += pDb->dbInf.databaseName; - s += "\n"; - - s += langDBINF_OUTER_JOINS; - s += pDb->dbInf.outerJoins; - s += "\n"; - - s += langDBINF_STORED_PROC; - s += pDb->dbInf.procedureSupport; - s += "\n"; - - if (pDb->dbInf.maxConnections) - t.sprintf("%s%d\n", langDBINF_MAX_HDBC, pDb->dbInf.maxConnections); - else - t.sprintf("%s%s\n", langDBINF_MAX_HDBC, langDBINF_UNLIMITED); - s += t; - - if (pDb->dbInf.maxStmts) - t.sprintf("%s%d\n", langDBINF_MAX_HSTMT, pDb->dbInf.maxStmts); - else - t.sprintf("%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 += "\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 += "\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 += "\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 += "\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 += "\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 += "\n"; - - s += langDBINF_SUPP_IEF; - s += pDb->dbInf.supportIEF; - s += "\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; + wxString s, t; + bool comma = FALSE; + + s = langDBINF_DB_NAME; + s += pDb->dbInf.dbmsName; + s += "\n"; + + s += langDBINF_DB_VER; + s += pDb->dbInf.dbmsVer; + s += "\n"; + + s += langDBINF_DRIVER_NAME; + s += pDb->dbInf.driverName; + s += "\n"; + + s += langDBINF_DRIVER_ODBC_VER; + s += pDb->dbInf.odbcVer; + s += "\n"; + + s += langDBINF_DRIVER_MGR_ODBC_VER; + s += pDb->dbInf.drvMgrOdbcVer; + s += "\n"; + + s += langDBINF_DRIVER_VER; + s += pDb->dbInf.driverVer; + s += "\n"; + + s += langDBINF_SERVER_NAME; + s += pDb->dbInf.serverName; + s += "\n"; + + s += langDBINF_FILENAME; + s += pDb->dbInf.databaseName; + s += "\n"; + + s += langDBINF_OUTER_JOINS; + s += pDb->dbInf.outerJoins; + s += "\n"; + + s += langDBINF_STORED_PROC; + s += pDb->dbInf.procedureSupport; + s += "\n"; + + if (pDb->dbInf.maxConnections) + t.sprintf("%s%d\n", langDBINF_MAX_HDBC, pDb->dbInf.maxConnections); + else + t.sprintf("%s%s\n", langDBINF_MAX_HDBC, langDBINF_UNLIMITED); + s += t; + + if (pDb->dbInf.maxStmts) + t.sprintf("%s%d\n", langDBINF_MAX_HSTMT, pDb->dbInf.maxStmts); + else + t.sprintf("%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 += "\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 += "\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 += "\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 += "\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 += "\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 += "\n"; + + s += langDBINF_SUPP_IEF; + s += pDb->dbInf.supportIEF; + s += "\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 += "\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; + case SQL_TXN_VERSIONING: s += langDBINF_VERSIONING; break; +#endif + } + s += "\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 += "\n"; - - 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 += ", "; s += langDBINF_READ_COMMITTED;} - if (pDb->dbInf.txnIsolationOptions & SQL_TXN_REPEATABLE_READ) - {if (comma++) s += ", "; s += langDBINF_REPEATABLE_READ;} - if (pDb->dbInf.txnIsolationOptions & SQL_TXN_SERIALIZABLE) - {if (comma++) s += ", "; s += langDBINF_SERIALIZABLE;} + case SQL_TXN_VERSIONING: s += langDBINF_VERSIONING; break; +#endif + } + } + s += "\n"; + + 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 += ", "; s += langDBINF_READ_COMMITTED;} + if (pDb->dbInf.txnIsolationOptions & SQL_TXN_REPEATABLE_READ) + {if (comma++) s += ", "; s += langDBINF_REPEATABLE_READ;} + if (pDb->dbInf.txnIsolationOptions & SQL_TXN_SERIALIZABLE) + {if (comma++) s += ", "; s += langDBINF_SERIALIZABLE;} #ifdef ODBC_V20 - if (pDb->dbInf.txnIsolationOptions & SQL_TXN_VERSIONING) - {if (comma++) s += ", "; s += langDBINF_VERSIONING;} -#endif - s += "\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 += ", "; s += langDBINF_PREV;} - if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_FIRST) - {if (comma++) s += ", "; s += langDBINF_FIRST;} - if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_LAST) - {if (comma++) s += ", "; s += langDBINF_LAST;} - if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_ABSOLUTE) - {if (comma++) s += ", "; s += langDBINF_ABSOLUTE;} - if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_RELATIVE) - {if (comma++) s += ", "; s += langDBINF_RELATIVE;} + if (pDb->dbInf.txnIsolationOptions & SQL_TXN_VERSIONING) + {if (comma++) s += ", "; s += langDBINF_VERSIONING;} +#endif + s += "\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 += ", "; s += langDBINF_PREV;} + if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_FIRST) + {if (comma++) s += ", "; s += langDBINF_FIRST;} + if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_LAST) + {if (comma++) s += ", "; s += langDBINF_LAST;} + if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_ABSOLUTE) + {if (comma++) s += ", "; s += langDBINF_ABSOLUTE;} + if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_RELATIVE) + {if (comma++) s += ", "; s += langDBINF_RELATIVE;} #ifdef ODBC_V20 - if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_RESUME) - {if (comma++) s += ", "; s += langDBINF_RESUME;} -#endif - if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_BOOKMARK) - {if (comma++) s += ", "; s += langDBINF_BOOKMARK;} - s += "\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 += ", "; s += langDBINF_EXCLUSIVE;} - if (pDb->dbInf.lockTypes & SQL_LCK_UNLOCK) - {if (comma++) s += ", "; s += langDBINF_UNLOCK;} - s += "\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 += ", "; s += langDBINF_REFRESH;} - if (pDb->dbInf.posOperations & SQL_POS_UPDATE) - {if (comma++) s += ", "; s += langDBINF_UPD;} - if (pDb->dbInf.posOperations & SQL_POS_DELETE) - {if (comma++) s += ", "; s += langDBINF_DEL;} - if (pDb->dbInf.posOperations & SQL_POS_ADD) - {if (comma++) s += ", "; s += langDBINF_ADD;} - s += "\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 += ", "; s += langDBINF_POS_UPD;} - if (pDb->dbInf.posStmts & SQL_PS_SELECT_FOR_UPDATE) - {if (comma++) s += ", "; s += langDBINF_SELECT_FOR_UPD;} - s += "\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 += ", "; s += langDBINF_LOCK;} - if (pDb->dbInf.scrollConcurrency & SQL_SCCO_OPT_ROWVER) - {if (comma++) s += ", "; s += langDBINF_OPT_ROWVER;} - if (pDb->dbInf.scrollConcurrency & SQL_SCCO_OPT_VALUES) - {if (comma++) s += ", "; s += langDBINF_OPT_VALUES;} - s += "\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 += ", "; s += langDBINF_STATIC;} - if (pDb->dbInf.scrollOptions & SQL_SO_KEYSET_DRIVEN) - {if (comma++) s += ", "; s += langDBINF_KEYSET_DRIVEN;} - if (pDb->dbInf.scrollOptions & SQL_SO_DYNAMIC) - {if (comma++) s += ", "; s += langDBINF_DYNAMIC;} - if (pDb->dbInf.scrollOptions & SQL_SO_MIXED) - {if (comma++) s += ", "; s += langDBINF_MIXED;} - s += "\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 += ", "; s += langDBINF_DELETIONS;} - if (pDb->dbInf.staticSensitivity & SQL_SS_UPDATES) - {if (comma++) s += ", "; s += langDBINF_UPDATES;} - s += "\n"; - - - 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 += "\n"; - - t.sprintf("%s%d\n", langDBINF_LOGIN_TIMEOUT, pDb->dbInf.loginTimeout); - s += t; - - // Oracle specific information - if (pDb->Dbms() == dbmsORACLE) - { - s += "\n"; - s += langDBINF_ORACLE_BANNER; - s += "\n"; - - // Oracle cache hit ratio - SDWORD cb; - ULONG dbBlockGets; - pDb->ExecSql("SELECT VALUE FROM V$SYSSTAT WHERE NAME = 'db block gets'"); - pDb->GetNext(); - if (pDb->GetData(1, SQL_C_ULONG, &dbBlockGets, 0, &cb)) - { - t.sprintf("%s: %lu\n", langDBINF_DB_BLOCK_GETS, dbBlockGets); - s += t; - } - - ULONG consistentGets; - pDb->ExecSql("SELECT VALUE FROM V$SYSSTAT WHERE NAME = 'consistent gets'"); - pDb->GetNext(); - if (pDb->GetData(1, SQL_C_ULONG, &consistentGets, 0, &cb)) - { - t.sprintf("%s: %lu\n", langDBINF_CONSISTENT_GETS, consistentGets); - s += t; - } - - ULONG physReads; - pDb->ExecSql("SELECT VALUE FROM V$SYSSTAT WHERE NAME = 'physical reads'"); - pDb->GetNext(); - if (pDb->GetData(1, SQL_C_ULONG, &physReads, 0, &cb)) - { - t.sprintf("%s: %lu\n", langDBINF_PHYSICAL_READS, physReads); - s += t; - } - - ULONG hitRatio = (ULONG)((1.00 - ((float)physReads / (float)(dbBlockGets + consistentGets))) * 100.00); - t.sprintf("*** %s: %lu%%\n", langDBINF_CACHE_HIT_RATIO, hitRatio); - s += t; - - // Tablespace information - s += "\n"; - s += langDBINF_TABLESPACE_IO; - s += "\n"; - ULONG physWrites; - char tablespaceName[257]; - pDb->ExecSql("SELECT NAME,PHYRDS,PHYWRTS FROM V$DATAFILE, V$FILESTAT WHERE V$DATAFILE.FILE# = V$FILESTAT.FILE#"); - while (pDb->GetNext()) - { - pDb->GetData(1, SQL_C_CHAR, tablespaceName, 257, &cb); - pDb->GetData(2, SQL_C_ULONG, &physReads, 0, &cb); - pDb->GetData(3, SQL_C_ULONG, &physWrites, 0, &cb); - t.sprintf("%s\n\t%s: %lu\t%s: %lu\n", tablespaceName, - langDBINF_PHYSICAL_READS, physReads, langDBINF_PHYSICAL_WRITES, physWrites); - s += t; - } - - s += "\n"; - } + if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_RESUME) + {if (comma++) s += ", "; s += langDBINF_RESUME;} +#endif + if (pDb->dbInf.fetchDirections & SQL_FD_FETCH_BOOKMARK) + {if (comma++) s += ", "; s += langDBINF_BOOKMARK;} + s += "\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 += ", "; s += langDBINF_EXCLUSIVE;} + if (pDb->dbInf.lockTypes & SQL_LCK_UNLOCK) + {if (comma++) s += ", "; s += langDBINF_UNLOCK;} + s += "\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 += ", "; s += langDBINF_REFRESH;} + if (pDb->dbInf.posOperations & SQL_POS_UPDATE) + {if (comma++) s += ", "; s += langDBINF_UPD;} + if (pDb->dbInf.posOperations & SQL_POS_DELETE) + {if (comma++) s += ", "; s += langDBINF_DEL;} + if (pDb->dbInf.posOperations & SQL_POS_ADD) + {if (comma++) s += ", "; s += langDBINF_ADD;} + s += "\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 += ", "; s += langDBINF_POS_UPD;} + if (pDb->dbInf.posStmts & SQL_PS_SELECT_FOR_UPDATE) + {if (comma++) s += ", "; s += langDBINF_SELECT_FOR_UPD;} + s += "\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 += ", "; s += langDBINF_LOCK;} + if (pDb->dbInf.scrollConcurrency & SQL_SCCO_OPT_ROWVER) + {if (comma++) s += ", "; s += langDBINF_OPT_ROWVER;} + if (pDb->dbInf.scrollConcurrency & SQL_SCCO_OPT_VALUES) + {if (comma++) s += ", "; s += langDBINF_OPT_VALUES;} + s += "\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 += ", "; s += langDBINF_STATIC;} + if (pDb->dbInf.scrollOptions & SQL_SO_KEYSET_DRIVEN) + {if (comma++) s += ", "; s += langDBINF_KEYSET_DRIVEN;} + if (pDb->dbInf.scrollOptions & SQL_SO_DYNAMIC) + {if (comma++) s += ", "; s += langDBINF_DYNAMIC;} + if (pDb->dbInf.scrollOptions & SQL_SO_MIXED) + {if (comma++) s += ", "; s += langDBINF_MIXED;} + s += "\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 += ", "; s += langDBINF_DELETIONS;} + if (pDb->dbInf.staticSensitivity & SQL_SS_UPDATES) + {if (comma++) s += ", "; s += langDBINF_UPDATES;} + s += "\n"; + + + 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 += "\n"; + + t.sprintf("%s%d\n", langDBINF_LOGIN_TIMEOUT, pDb->dbInf.loginTimeout); + s += t; + + // Oracle specific information + if (pDb->Dbms() == dbmsORACLE) + { + s += "\n"; + s += langDBINF_ORACLE_BANNER; + s += "\n"; + + // Oracle cache hit ratio + SDWORD cb; + ULONG dbBlockGets; + pDb->ExecSql("SELECT VALUE FROM V$SYSSTAT WHERE NAME = 'db block gets'"); + pDb->GetNext(); + if (pDb->GetData(1, SQL_C_ULONG, &dbBlockGets, 0, &cb)) + { + t.sprintf("%s: %lu\n", langDBINF_DB_BLOCK_GETS, dbBlockGets); + s += t; + } + + ULONG consistentGets; + pDb->ExecSql("SELECT VALUE FROM V$SYSSTAT WHERE NAME = 'consistent gets'"); + pDb->GetNext(); + if (pDb->GetData(1, SQL_C_ULONG, &consistentGets, 0, &cb)) + { + t.sprintf("%s: %lu\n", langDBINF_CONSISTENT_GETS, consistentGets); + s += t; + } + + ULONG physReads; + pDb->ExecSql("SELECT VALUE FROM V$SYSSTAT WHERE NAME = 'physical reads'"); + pDb->GetNext(); + if (pDb->GetData(1, SQL_C_ULONG, &physReads, 0, &cb)) + { + t.sprintf("%s: %lu\n", langDBINF_PHYSICAL_READS, physReads); + s += t; + } + + ULONG hitRatio = (ULONG)((1.00 - ((float)physReads / (float)(dbBlockGets + consistentGets))) * 100.00); + t.sprintf("*** %s: %lu%%\n", langDBINF_CACHE_HIT_RATIO, hitRatio); + s += t; + + // Tablespace information + s += "\n"; + s += langDBINF_TABLESPACE_IO; + s += "\n"; + ULONG physWrites; + char tablespaceName[257]; + pDb->ExecSql("SELECT NAME,PHYRDS,PHYWRTS FROM V$DATAFILE, V$FILESTAT WHERE V$DATAFILE.FILE# = V$FILESTAT.FILE#"); + while (pDb->GetNext()) + { + pDb->GetData(1, SQL_C_CHAR, tablespaceName, 257, &cb); + pDb->GetData(2, SQL_C_ULONG, &physReads, 0, &cb); + pDb->GetData(3, SQL_C_ULONG, &physWrites, 0, &cb); + t.sprintf("%s\n\t%s: %lu\t%s: %lu\n", tablespaceName, + langDBINF_PHYSICAL_READS, physReads, langDBINF_PHYSICAL_WRITES, physWrites); + s += t; + } + + s += "\n"; + } wxLogMessage(s); } // 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