#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)
{
wxDbSqlTypeInfo sqlTypeInfo;
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