X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/74de91cc974062b9eaddc7c0ccbfb07013bd0611..4efdef2c87d09736304fcc41d312fa80ad544b92:/demos/dbbrowse/browsedb.cpp diff --git a/demos/dbbrowse/browsedb.cpp b/demos/dbbrowse/browsedb.cpp index 9583c776b1..c3761a7618 100644 --- a/demos/dbbrowse/browsedb.cpp +++ b/demos/dbbrowse/browsedb.cpp @@ -1,12 +1,12 @@ //---------------------------------------------------------------------------------------- -// Name: BrowserDB.h,cpp -// Purpose: a wxDB class -// Author: Mark Johnson +// Name: BrowserDB.h,cpp +// Purpose: a wxDB class +// Author: Mark Johnson // Modified by: -// Created: 19991127.mj10777 -// Copyright: (c) Mark Johnson -// Licence: wxWindows license -// RCS-ID: $Id$ +// Created: 19991127.mj10777 +// Copyright: (c) Mark Johnson +// Licence: wxWindows license +// RCS-ID: $Id$ //---------------------------------------------------------------------------------------- //-- 1) //---------------------------------------------------------------------------------------- @@ -38,7 +38,7 @@ wxDbConnectInf DbConnectInf; #endif //---------------------------------------------------------------------------------------- -extern WXDLLEXPORT_DATA(wxDbList*) PtrBegDbList; /* from db.cpp, used in getting back error results from db connections */ +extern WXDLLEXPORT_DATA(wxDbList*) PtrBegDbList; /* from db.cpp, used in getting back error results from db connections */ //---------------------------------------------------------------------------------------- wxChar *GetExtendedDBErrorMsg(wxChar *ErrFile, int ErrLine) @@ -102,9 +102,9 @@ bool BrowserDB::Initialize(int Quiet) if (!OnStartDB(Quiet)) { wxLogMessage(_("\n\n-E-> BrowserDB::OnStartDB(%s) : Failed ! "),ODBCSource.c_str()); - return FALSE; + return false; } - return TRUE; + return true; } // BrowserDB:Initialize //---------------------------------------------------------------------------------------- @@ -117,7 +117,7 @@ bool BrowserDB::OnStartDB(int Quiet) { if (!Quiet) wxLogMessage(_("\n-I-> BrowserDB::OnStartDB() : DB is already open.")); - return TRUE; + return true; } DbConnectInf.AllocHenv(); @@ -127,28 +127,28 @@ bool BrowserDB::OnStartDB(int Quiet) //--------------------------------------------------------------------------------------- DlgUser *p_Dlg; p_Dlg = new DlgUser(pDoc->p_MainFrame,pDoc,_T("")); - p_Dlg->s_DSN = ODBCSource; - p_Dlg->s_User = UserName; + p_Dlg->s_DSN = ODBCSource; + p_Dlg->s_User = UserName; p_Dlg->s_Password = Password; p_Dlg->OnInit(); p_Dlg->Fit(); - - bool OK = FALSE; + + bool OK = false; if (p_Dlg->ShowModal() == wxID_OK) { (pDoc->p_DSN+i_Which)->Usr = p_Dlg->s_User; (pDoc->p_DSN+i_Which)->Pas = p_Dlg->s_Password; UserName = p_Dlg->s_User; Password = p_Dlg->s_Password; - OK = TRUE; + OK = true; } delete p_Dlg; if (OK) { //-------------------------------------------------------------------------------------- - DbConnectInf.SetDsn(ODBCSource); // ODBC data source name (created with ODBC Administrator under Win95/NT) - DbConnectInf.SetUserID(UserName); // database username - must already exist in the data source - DbConnectInf.SetPassword(Password); // password database username + DbConnectInf.SetDsn(ODBCSource); // ODBC data source name (created with ODBC Administrator under Win95/NT) + DbConnectInf.SetUserID(UserName); // database username - must already exist in the data source + DbConnectInf.SetPassword(Password); // password database username db_BrowserDB = wxDbGetConnection(&DbConnectInf); // wxLogMessage(">>>%s<<<>>>%s<<<",UserName.c_str(),Password.c_str()); if (db_BrowserDB == NULL) @@ -162,7 +162,7 @@ bool BrowserDB::OnStartDB(int Quiet) wxLogMessage(_("-I-> BrowserDB::OnStartDB(%s) : End - Time needed : %ld ms"),ODBCSource.c_str(),sw.Time()); } DbConnectInf.FreeHenv(); - return FALSE; + return false; } //-------------------------------------------------------------------------------------- if (!Quiet) @@ -172,12 +172,12 @@ bool BrowserDB::OnStartDB(int Quiet) wxLogMessage(_("-I-> BrowserDB::OnGetDataSourceODBC() - DatabaseName(%s) ; DataSource(%s)"),Temp1.c_str(),Temp2.c_str()); wxLogMessage(_("-I-> BrowserDB::OnStartDB(%s) : End - Time needed : %ld ms"),ODBCSource.c_str(),sw.Time()); } - return TRUE; + return true; } else { DbConnectInf.FreeHenv(); - return FALSE; + return false; } } @@ -197,19 +197,18 @@ bool BrowserDB::OnCloseDB(int Quiet) } if (!Quiet) wxLogMessage(_("\n-I-> BrowserDB::OnCloseDB() : End ")); - return TRUE; + return true; } //---------------------------------------------------------------------------------------- bool BrowserDB::OnGetNext(int Cols,int WXUNUSED(Quiet)) { SDWORD cb; - int i_dbDataType; - int i=0; + int i_dbDataType; wxChar s_temp[1024+1]; - long l_temp; - double f_temp; - int AnzError=0; + long l_temp; + double f_temp; + int AnzError=0; TIMESTAMP_STRUCT t_temp; wxString Temp0; //----------------------------- @@ -221,18 +220,19 @@ bool BrowserDB::OnGetNext(int Cols,int WXUNUSED(Quiet)) wxLogMessage(Temp0); wxMessageBox(Temp0); #endif - return FALSE; + return false; } else { + int i; for (i=0;itableName,_T("-E->")); i_dbDataType = (cl_BrowserDB+i)->pColFor->i_dbDataType; - if (i_dbDataType == 0) // Filter unsupported dbDataTypes + if (i_dbDataType == 0) // Filter unsupported dbDataTypes { if (((cl_BrowserDB+i)->pColFor->i_sqlDataType == SQL_VARCHAR) || - ((cl_BrowserDB+i)->pColFor->i_sqlDataType == SQL_LONGVARCHAR)) + ((cl_BrowserDB+i)->pColFor->i_sqlDataType == SQL_LONGVARCHAR)) i_dbDataType = DB_DATA_TYPE_VARCHAR; if ((cl_BrowserDB+i)->pColFor->i_sqlDataType == SQL_C_DATE) i_dbDataType = DB_DATA_TYPE_DATE; @@ -244,15 +244,15 @@ bool BrowserDB::OnGetNext(int Cols,int WXUNUSED(Quiet)) i_dbDataType = DB_DATA_TYPE_FLOAT; } if ((i_dbDataType == DB_DATA_TYPE_INTEGER) && - ((cl_BrowserDB+i)->pColFor->i_sqlDataType == SQL_C_DOUBLE)) - { // DBASE Numeric + ((cl_BrowserDB+i)->pColFor->i_sqlDataType == SQL_C_DOUBLE)) + { // DBASE Numeric i_dbDataType = DB_DATA_TYPE_FLOAT; } switch(i_dbDataType) { case DB_DATA_TYPE_VARCHAR: wxStrcpy(s_temp,_T("")); - if (!db_BrowserDB->GetData(i+1,(cl_BrowserDB+i)->pColFor->i_dbDataType,&s_temp,sizeof(s_temp), &cb)) + if (!db_BrowserDB->GetData((UWORD)(i+1),(SWORD)((cl_BrowserDB+i)->pColFor->i_dbDataType),&s_temp[0],sizeof(s_temp), &cb)) { Temp0.Printf(_("\n-E-> BrowserDB::OnGetNext - ODBC-Error with GetNext of >%s<.\n-E-> "),(cl_BrowserDB+i)->tableName); Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); @@ -263,7 +263,7 @@ bool BrowserDB::OnGetNext(int Cols,int WXUNUSED(Quiet)) break; case DB_DATA_TYPE_INTEGER: l_temp = 0; - if (!db_BrowserDB->GetData(i+1,(cl_BrowserDB+i)->pColFor->i_sqlDataType,&l_temp,sizeof(l_temp), &cb)) + if (!db_BrowserDB->GetData((UWORD)(i+1),(SWORD)((cl_BrowserDB+i)->pColFor->i_sqlDataType),&l_temp,sizeof(l_temp), &cb)) { Temp0.Printf(_("\n-E-> BrowserDB::OnGetData - ODBC-Error with GetNext \n-E-> ")); Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); @@ -276,7 +276,7 @@ bool BrowserDB::OnGetNext(int Cols,int WXUNUSED(Quiet)) break; case DB_DATA_TYPE_FLOAT: f_temp = 0; - if (!db_BrowserDB->GetData(i+1,(cl_BrowserDB+i)->pColFor->i_sqlDataType,&f_temp,sizeof(f_temp), &cb)) + if (!db_BrowserDB->GetData((UWORD)(i+1),(SWORD)((cl_BrowserDB+i)->pColFor->i_sqlDataType),&f_temp,sizeof(f_temp), &cb)) { Temp0.Printf(_("\n-E-> BrowserDB::OnGetData - ODBC-Error with GetNext \n-E-> ")); Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); @@ -289,8 +289,14 @@ bool BrowserDB::OnGetNext(int Cols,int WXUNUSED(Quiet)) } break; case DB_DATA_TYPE_DATE: - t_temp.day = t_temp.month = t_temp.year = t_temp.hour = t_temp.minute = t_temp.second = t_temp.fraction = 0; - if (!db_BrowserDB->GetData(i+1,(cl_BrowserDB+i)->pColFor->i_sqlDataType,&t_temp,sizeof(t_temp), &cb)) + t_temp.day = 0; + t_temp.month = 0; + t_temp.year = 0; + t_temp.hour = 0; + t_temp.minute = 0; + t_temp.second = 0; + t_temp.fraction = 0; + if (!db_BrowserDB->GetData((UWORD)(i+1),(SWORD)((cl_BrowserDB+i)->pColFor->i_sqlDataType),&t_temp,sizeof(t_temp), &cb)) { Temp0.Printf(_("\n-E-> BrowserDB::OnGetData - ODBC-Error with GetNext \n-E-> ")); Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); @@ -298,8 +304,8 @@ bool BrowserDB::OnGetNext(int Cols,int WXUNUSED(Quiet)) else { // i_Nation = 0 = timestamp , 1=EU, 2=UK, 3=International, 4=US - if (((cl_BrowserDB+i)->pColFor->i_Nation == 0) || // TS YYYY-MM-DD - ((cl_BrowserDB+i)->pColFor->i_Nation == 3)) // IT YYYY-MM-DD + if (((cl_BrowserDB+i)->pColFor->i_Nation == 0) || // TS YYYY-MM-DD + ((cl_BrowserDB+i)->pColFor->i_Nation == 3)) // IT YYYY-MM-DD { Temp0.Printf((cl_BrowserDB+i)->pColFor->s_Field,t_temp.year,t_temp.month,t_temp.day, t_temp.hour, t_temp.minute, t_temp.second, t_temp.fraction); @@ -312,7 +318,7 @@ bool BrowserDB::OnGetNext(int Cols,int WXUNUSED(Quiet)) t_temp.hour, t_temp.minute, t_temp.second, t_temp.fraction); wxStrcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); } - if ((cl_BrowserDB+i)->pColFor->i_Nation == 3) // US MM/DD/YYYY + if ((cl_BrowserDB+i)->pColFor->i_Nation == 3) // US MM/DD/YYYY { Temp0.Printf((cl_BrowserDB+i)->pColFor->s_Field,t_temp.month,t_temp.day,t_temp.year, t_temp.hour, t_temp.minute, t_temp.second, t_temp.fraction); @@ -328,7 +334,7 @@ bool BrowserDB::OnGetNext(int Cols,int WXUNUSED(Quiet)) wxLogMessage(_("-E-> BrowserDB::OnGetNext - DB_DATA_TYPE_?? (%d) in Col(%s)"),(cl_BrowserDB+i)->pColFor->i_dbDataType,Temp0.c_str()); } else - return TRUE; + return true; Temp0.Printf(_("-E-> unknown Format(%d) - sql(%d)"),(cl_BrowserDB+i)->pColFor->i_dbDataType,(cl_BrowserDB+i)->pColFor->i_sqlDataType); wxStrcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); break; @@ -336,7 +342,7 @@ bool BrowserDB::OnGetNext(int Cols,int WXUNUSED(Quiet)) } // for } // else - return TRUE; + return true; } //---------------------------------------------------------------------------------------- @@ -354,7 +360,7 @@ bool BrowserDB::OnSelect(wxString tb_Name, int Quiet) Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); wxLogMessage(Temp0); wxMessageBox(_T("-E-> BrowserDB::OnSelect - GetData()")); - return FALSE; + return false; } //--------------------------------------------------------------------------------------- while (db_BrowserDB->GetNext()) @@ -367,16 +373,16 @@ bool BrowserDB::OnSelect(wxString tb_Name, int Quiet) Temp0.Printf(_("\n-E-> BrowserDB::OnSelect - ODBC-Error with ExecSql of >%s<.\n-E-> "),tb_Name.c_str()); Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); wxLogMessage(Temp0); - return FALSE; + return false; } //--------------------------------------------------------------------------------------- - // SetColDefs ( 0,"NAME", DB_DATA_TYPE_VARCHAR, Name, SQL_C_CHAR, sizeof(Name), TRUE, TRUE); // Primary index + // SetColDefs ( 0,"NAME",DB_DATA_TYPE_VARCHAR,Name,SQL_C_CHAR,sizeof(Name),true,true); // Primary index //--------------------------------------------------------------------------------------- if (!Quiet) { wxLogMessage(_("\n-I-> BrowserDB::OnSelect(%s) Records(%d): End - Time needed : %ld ms"),tb_Name.c_str(),i_Records,sw.Time()); } - return TRUE; + return true; } //---------------------------------------------------------------------------------------- @@ -391,13 +397,13 @@ bool BrowserDB::OnExecSql(wxString SQLStmt, int Quiet) wxLogMessage(Temp0); else wxMessageBox(_T("-E-> BrowserDB::OnExecSql - ExecSql()")); - return FALSE; + return false; } if (!Quiet) { // wxLogMessage(_("\n-I-> BrowserDB::OnExecSql(%s) - End - Time needed : %ld ms"),SQLStmt.c_str(),sw.Time()); } - return TRUE; + return true; } //---------------------------------------------------------------------------------------- @@ -425,7 +431,7 @@ wxDbColInf* BrowserDB::OnGetColumns(wxChar *tableName, UWORD numCols, int WXUNUS (cl_BrowserDB+i)->pColFor->Format(1, (cl_BrowserDB+i)->dbDataType, (cl_BrowserDB+i)->sqlDataType, - (cl_BrowserDB+i)->columnSize, + (cl_BrowserDB+i)->columnSize, (cl_BrowserDB+i)->decimalDigits); } return cl_BrowserDB; @@ -452,10 +458,10 @@ void BrowserDB::PointerToNULL(int Art) delete db_BrowserDB; } } - cl_BrowserDB = NULL; - ct_BrowserDB = NULL; - db_BrowserDB = NULL; - p_LogWindow = NULL; + cl_BrowserDB = NULL; + ct_BrowserDB = NULL; + db_BrowserDB = NULL; + p_LogWindow = NULL; } //----------------------------------------------------------------------------------------