X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/243d4b360385d3364e96d5600f693139e359fb3b..c7fa61e5ec4ac323c865adeb01e0c9f232faae20:/demos/dbbrowse/browsedb.cpp diff --git a/demos/dbbrowse/browsedb.cpp b/demos/dbbrowse/browsedb.cpp index 569730e1ae..9583c776b1 100644 --- a/demos/dbbrowse/browsedb.cpp +++ b/demos/dbbrowse/browsedb.cpp @@ -31,8 +31,7 @@ #include "std.h" //---------------------------------------------------------------------------------------- // Global structure for holding ODBC connection information -// - darf nur einmal im Projekte definiert werden ?? Extra Databasse Klasse ? -wxDbConnectInf DbConnectInf; // Für DBase +wxDbConnectInf DbConnectInf; #if !wxUSE_ODBC #error Demo cannot be compiled unless setup.h has wxUSE_ODBC set to 1 @@ -42,21 +41,21 @@ wxDbConnectInf DbConnectInf; // F extern WXDLLEXPORT_DATA(wxDbList*) PtrBegDbList; /* from db.cpp, used in getting back error results from db connections */ //---------------------------------------------------------------------------------------- -char *GetExtendedDBErrorMsg(char *ErrFile, int ErrLine) +wxChar *GetExtendedDBErrorMsg(wxChar *ErrFile, int ErrLine) { static wxString msg; wxString tStr; if (ErrFile || ErrLine) { - msg += "File: "; + msg += _T("File: "); msg += ErrFile; - msg += " Line: "; - tStr.Printf("%d",ErrLine); + msg += _T(" Line: "); + tStr.Printf(_T("%d"),ErrLine); msg += tStr.GetData(); - // msg += "\n"; + // msg += _T("\n"); } - msg.Append ("\nODBC errors:\n"); - // msg += "\n"; + msg.Append (_T("\nODBC errors:\n")); + // msg += _T("\n"); /* Scan through each database connection displaying * any ODBC errors that have occured. */ wxDbList *pDbList; @@ -71,22 +70,22 @@ char *GetExtendedDBErrorMsg(char *ErrFile, int ErrLine) if (pDbList->PtrDb->errorList[i]) { msg.Append(pDbList->PtrDb->errorList[i]); - if (strcmp(pDbList->PtrDb->errorList[i],"") != 0) - msg.Append("\n"); + if (wxStrcmp(pDbList->PtrDb->errorList[i],_T("")) != 0) + msg.Append(_T("\n")); } } } - msg += "\n"; - return (char*) (const char*) msg; + msg += _T("\n"); + return (wxChar*) (const wxChar*) msg; } // GetExtendedDBErrorMsg //---------------------------------------------------------------------------------------- BrowserDB::BrowserDB() { PointerToNULL(0); - ODBCSource = ""; // ODBC data source name (created with ODBC Administrator under Win95/NT) - UserName = ""; // database username - must already exist in the data source - Password = ""; // password database username + ODBCSource = _T(""); // ODBC data source name (created with ODBC Administrator under Win95/NT) + UserName = _T(""); // database username - must already exist in the data source + Password = _T(""); // password database username OnFillSqlTyp(); OnFilldbTyp(); } // BrowserDB Constructor @@ -127,7 +126,7 @@ bool BrowserDB::OnStartDB(int Quiet) // Connect to datasource //--------------------------------------------------------------------------------------- DlgUser *p_Dlg; - p_Dlg = new DlgUser(pDoc->p_MainFrame,pDoc,""); + p_Dlg = new DlgUser(pDoc->p_MainFrame,pDoc,_T("")); p_Dlg->s_DSN = ODBCSource; p_Dlg->s_User = UserName; p_Dlg->s_Password = Password; @@ -202,12 +201,12 @@ bool BrowserDB::OnCloseDB(int Quiet) } //---------------------------------------------------------------------------------------- -bool BrowserDB::OnGetNext(int Cols,int Quiet) +bool BrowserDB::OnGetNext(int Cols,int WXUNUSED(Quiet)) { SDWORD cb; int i_dbDataType; int i=0; - char s_temp[1024+1]; + wxChar s_temp[1024+1]; long l_temp; double f_temp; int AnzError=0; @@ -216,17 +215,19 @@ bool BrowserDB::OnGetNext(int Cols,int Quiet) //----------------------------- if (!db_BrowserDB->GetNext()) { - return FALSE; +#ifdef __WXDEBUG__ Temp0.Printf(_("\n-E-> BrowserDB::OnGetNext - ODBC-Error with GetNext \n-E-> ")); - Temp0 += GetExtendedDBErrorMsg(__FILE__,__LINE__); + Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); wxLogMessage(Temp0); wxMessageBox(Temp0); +#endif + return FALSE; } else { for (i=0;itableName,"-E->"); + wxStrcpy((cl_BrowserDB+i)->tableName,_T("-E->")); i_dbDataType = (cl_BrowserDB+i)->pColFor->i_dbDataType; if (i_dbDataType == 0) // Filter unsupported dbDataTypes { @@ -250,27 +251,27 @@ bool BrowserDB::OnGetNext(int Cols,int Quiet) switch(i_dbDataType) { case DB_DATA_TYPE_VARCHAR: - strcpy(s_temp,""); + wxStrcpy(s_temp,_T("")); if (!db_BrowserDB->GetData(i+1,(cl_BrowserDB+i)->pColFor->i_dbDataType,&s_temp,sizeof(s_temp), &cb)) { Temp0.Printf(_("\n-E-> BrowserDB::OnGetNext - ODBC-Error with GetNext of >%s<.\n-E-> "),(cl_BrowserDB+i)->tableName); - Temp0 += GetExtendedDBErrorMsg(__FILE__,__LINE__); + Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); wxLogMessage(Temp0); } Temp0.Printf((cl_BrowserDB+i)->pColFor->s_Field,s_temp); - strcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); + wxStrcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); 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)) { Temp0.Printf(_("\n-E-> BrowserDB::OnGetData - ODBC-Error with GetNext \n-E-> ")); - Temp0 += GetExtendedDBErrorMsg(__FILE__,__LINE__); + Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); } else { Temp0.Printf((cl_BrowserDB+i)->pColFor->s_Field,l_temp); - strcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); + wxStrcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); } break; case DB_DATA_TYPE_FLOAT: @@ -278,13 +279,13 @@ bool BrowserDB::OnGetNext(int Cols,int Quiet) if (!db_BrowserDB->GetData(i+1,(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(__FILE__,__LINE__); + Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); wxMessageBox(Temp0); } else { Temp0.Printf((cl_BrowserDB+i)->pColFor->s_Field,f_temp); - strcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); + wxStrcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); } break; case DB_DATA_TYPE_DATE: @@ -292,7 +293,7 @@ bool BrowserDB::OnGetNext(int Cols,int Quiet) if (!db_BrowserDB->GetData(i+1,(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(__FILE__,__LINE__); + Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); } else { @@ -302,20 +303,20 @@ bool BrowserDB::OnGetNext(int Cols,int Quiet) { 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); - strcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); + wxStrcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); } if (((cl_BrowserDB+i)->pColFor->i_Nation == 1) || // EU DD.MM.YYYY ((cl_BrowserDB+i)->pColFor->i_Nation == 2)) // UK DD/MM/YYYY { Temp0.Printf((cl_BrowserDB+i)->pColFor->s_Field,t_temp.day,t_temp.month,t_temp.year, t_temp.hour, t_temp.minute, t_temp.second, t_temp.fraction); - strcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); + wxStrcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); } 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); - strcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); + wxStrcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); } } break; @@ -329,7 +330,7 @@ bool BrowserDB::OnGetNext(int Cols,int Quiet) else return TRUE; Temp0.Printf(_("-E-> unknown Format(%d) - sql(%d)"),(cl_BrowserDB+i)->pColFor->i_dbDataType,(cl_BrowserDB+i)->pColFor->i_sqlDataType); - strcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); + wxStrcpy((cl_BrowserDB+i)->tableName,Temp0.c_str()); break; }; // switch } // for @@ -345,13 +346,14 @@ bool BrowserDB::OnSelect(wxString tb_Name, int Quiet) wxString SQLStmt; i_Records = 0; //--------------------------------------------------------------------------------------- - SQLStmt.sprintf("SELECT * FROM %s",db_BrowserDB->SQLTableName(tb_Name.c_str())); - if (!db_BrowserDB->ExecSql((char *)(SQLStmt.GetData()))) + wxString tablename = db_BrowserDB->SQLTableName(tb_Name.c_str()); + SQLStmt.sprintf(_T("SELECT * FROM %s"),tablename.c_str()); + if (!db_BrowserDB->ExecSql((wxChar *)(SQLStmt.GetData()))) { Temp0.Printf(_("\n-E-> BrowserDB::OnSelect - ODBC-Error with ExecSql of >%s<.\n-E-> "),tb_Name.c_str()); - Temp0 += GetExtendedDBErrorMsg(__FILE__,__LINE__); + Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); wxLogMessage(Temp0); - wxMessageBox("-E-> BrowserDB::OnSelect - GetData()"); + wxMessageBox(_T("-E-> BrowserDB::OnSelect - GetData()")); return FALSE; } //--------------------------------------------------------------------------------------- @@ -360,10 +362,10 @@ bool BrowserDB::OnSelect(wxString tb_Name, int Quiet) i_Records++; } //--------------------------------------------------------------------------------------- - if (!db_BrowserDB->ExecSql((char *)(SQLStmt.GetData()))) + if (!db_BrowserDB->ExecSql((wxChar *)(SQLStmt.GetData()))) { Temp0.Printf(_("\n-E-> BrowserDB::OnSelect - ODBC-Error with ExecSql of >%s<.\n-E-> "),tb_Name.c_str()); - Temp0 += GetExtendedDBErrorMsg(__FILE__,__LINE__); + Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); wxLogMessage(Temp0); return FALSE; } @@ -381,14 +383,14 @@ bool BrowserDB::OnSelect(wxString tb_Name, int Quiet) bool BrowserDB::OnExecSql(wxString SQLStmt, int Quiet) { //--------------------------------------------------------------------------------------- - if (!db_BrowserDB->ExecSql((char *)(SQLStmt.GetData()))) + if (!db_BrowserDB->ExecSql((wxChar *)(SQLStmt.GetData()))) { Temp0.Printf(_("\n-E-> BrowserDB::OnExecSQL - ODBC-Error with ExecSql of >%s<.\n-E-> "),SQLStmt.c_str()); - Temp0 += GetExtendedDBErrorMsg(__FILE__,__LINE__); + Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__); if (!Quiet) wxLogMessage(Temp0); else - wxMessageBox("-E-> BrowserDB::OnExecSql - ExecSql()"); + wxMessageBox(_T("-E-> BrowserDB::OnExecSql - ExecSql()")); return FALSE; } if (!Quiet) @@ -399,20 +401,20 @@ bool BrowserDB::OnExecSql(wxString SQLStmt, int Quiet) } //---------------------------------------------------------------------------------------- -wxDbInf* BrowserDB::OnGetCatalog(int Quiet) +wxDbInf* BrowserDB::OnGetCatalog(int WXUNUSED(Quiet)) { - char UName[255]; - strcpy(UName,UserName); + wxChar UName[255]; + wxStrcpy(UName,UserName); ct_BrowserDB = db_BrowserDB->GetCatalog(UName); return ct_BrowserDB; } //---------------------------------------------------------------------------------------- -wxDbColInf* BrowserDB::OnGetColumns(char *tableName, UWORD numCols, int Quiet) +wxDbColInf* BrowserDB::OnGetColumns(wxChar *tableName, UWORD numCols, int WXUNUSED(Quiet)) { - char UName[255]; + wxChar UName[255]; int i; - strcpy(UName,UserName); + wxStrcpy(UName,UserName); cl_BrowserDB = db_BrowserDB->GetColumns(tableName,&numCols,UName); // cl_BrowserDB->pColFor = new wxDbColFor[numCols]; for (i=0;i