X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5151c7af137a1b6f3c8f656048cf7d13524f040e..c3fad64b429a8f88396ad3b1693b611206ee8ee5:/demos/dbbrowse/doc.cpp?ds=sidebyside diff --git a/demos/dbbrowse/doc.cpp b/demos/dbbrowse/doc.cpp index b16d76bd01..c8044d37a1 100644 --- a/demos/dbbrowse/doc.cpp +++ b/demos/dbbrowse/doc.cpp @@ -144,17 +144,19 @@ bool MainDoc::OnInitView() // return false; OnInitODBC(); //--------------------------------------------------------------------------------------- +#if wxUSE_STATUSBAR Temp0.Printf(_("-I-> MainDoc::OnInitView() - End - %d DSN's found"),i_DSN); p_MainFrame->SetStatusText(Temp0, 0); wxLogMessage(Temp0); +#endif // wxUSE_STATUSBAR return true; } //---------------------------------------------------------------------------------------- bool MainDoc::OnInitODBC() { - wxChar Dsn[SQL_MAX_DSN_LENGTH + 1]; - wxChar DsDesc[255]; // BJO20002501 instead of 512 + wxChar Dsn[SQL_MAX_DSN_LENGTH+1]; + wxChar DsDesc[254+1]; // BJO20002501 instead of 512 Temp0 = _T(""); i_DSN = 0; // Counter int i; @@ -167,45 +169,40 @@ bool MainDoc::OnInitODBC() } //--------------------------------------------------------------------------------------- - const char sep = 3; // separator character used in string between DSN ans DsDesc - wxStringList s_SortDSNList, s_SortDsDescList; + const wxChar sep = 3; // separator character used in string between DSN and DsDesc + wxSortedArrayString s_SortDSNList, s_SortDsDescList; // BJO-20000127 // In order to have same sort result on both Dsn and DsDesc, create a 'keyed' string. // The key will be removed after sorting wxString KeyString; //--------------------------------------------------------------------------------------- - while(wxDbGetDataSource(DbConnectInf.GetHenv(), Dsn, sizeof(Dsn), DsDesc, sizeof(DsDesc))) + while (wxDbGetDataSource(DbConnectInf.GetHenv(), Dsn, SQL_MAX_DSN_LENGTH, DsDesc, 254)) { i_DSN++; // How many Dsn have we ? KeyString.Printf(_T("%s%c%s"),Dsn, sep, DsDesc); s_SortDSNList.Add(Dsn); s_SortDsDescList.Add(KeyString); } - s_SortDSNList.Sort(); //BJO - s_SortDsDescList.Sort(); //BJO - wxChar ** s_SortDSN = s_SortDSNList.ListToArray(); //BJO - wxChar ** s_SortDsDesc = s_SortDsDescList.ListToArray(); //BJO //--------------------------------------------------------------------------------------- // Allocate n ODBC-DSN objects to hold the information + // Allocate n wxDatabase objects to hold the column information p_DSN = new DSN[i_DSN]; //BJO + db_Br = new BrowserDB[i_DSN]; for (i=0;iDsn = s_SortDSN[i]; - (p_DSN+i)->Drv = s_SortDsDesc[i]; + + // ODBC-DSN object + (p_DSN+i)->Dsn = s_SortDSNList[i]; + (p_DSN+i)->Drv = KeyString; (p_DSN+i)->Usr = _T(""); (p_DSN+i)->Pas = _T(""); Temp0.Printf(_T("%02d) Dsn(%s) DsDesc(%s)"),i,(p_DSN+i)->Dsn.c_str(),(p_DSN+i)->Drv.c_str()); wxLogMessage(Temp0); - } - //--------------------------------------------------------------------------------------- - // Allocate n wxDatabase objects to hold the column information - db_Br = new BrowserDB[i_DSN]; - for (i=0;ip_LogWindow = p_LogWin; (db_Br+i)->ODBCSource = (p_DSN+i)->Dsn; (db_Br+i)->UserName = (p_DSN+i)->Usr; @@ -216,8 +213,6 @@ bool MainDoc::OnInitODBC() DbConnectInf.FreeHenv(); - delete [] s_SortDSN; - delete [] s_SortDsDesc; //--------------------------------------------------------------------------------------- if (!i_DSN) {