]> git.saurik.com Git - wxWidgets.git/blobdiff - demos/dbbrowse/browsedb.cpp
wxMediaCtrl patch from Ryan:
[wxWidgets.git] / demos / dbbrowse / browsedb.cpp
index b616eff639ec49beabcd7bbdc7506d40861d301f..d4f2ffbc0e5223fab0ad92c90c3f0bf676555c96 100644 (file)
@@ -57,7 +57,7 @@ wxChar *GetExtendedDBErrorMsg(wxChar *ErrFile, int ErrLine)
     msg.Append (_T("\nODBC errors:\n"));
     // msg += _T("\n");
     /* Scan through each database connection displaying
     msg.Append (_T("\nODBC errors:\n"));
     // msg += _T("\n");
     /* Scan through each database connection displaying
-    * any ODBC errors that have occured. */
+    * any ODBC errors that have occurred. */
     wxDbList *pDbList;
     for (pDbList = PtrBegDbList; pDbList; pDbList = pDbList->PtrNext)
     {
     wxDbList *pDbList;
     for (pDbList = PtrBegDbList; pDbList; pDbList = pDbList->PtrNext)
     {
@@ -70,7 +70,7 @@ wxChar *GetExtendedDBErrorMsg(wxChar *ErrFile, int ErrLine)
             if (pDbList->PtrDb->errorList[i])
             {
                 msg.Append(pDbList->PtrDb->errorList[i]);
             if (pDbList->PtrDb->errorList[i])
             {
                 msg.Append(pDbList->PtrDb->errorList[i]);
-                if (wxStrcmp(pDbList->PtrDb->errorList[i],_T("")) != 0)
+                if (wxStrcmp(pDbList->PtrDb->errorList[i],wxEmptyString) != 0)
                     msg.Append(_T("\n"));
             }
         }
                     msg.Append(_T("\n"));
             }
         }
@@ -83,9 +83,9 @@ wxChar *GetExtendedDBErrorMsg(wxChar *ErrFile, int ErrLine)
 BrowserDB::BrowserDB()
 {
     PointerToNULL(0);
 BrowserDB::BrowserDB()
 {
     PointerToNULL(0);
-    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
+    ODBCSource = wxEmptyString;  // ODBC data source name (created with ODBC Administrator under Win95/NT)
+    UserName   = wxEmptyString;  // database username - must already exist in the data source
+    Password   = wxEmptyString;  // password database username
     OnFillSqlTyp();
     OnFilldbTyp();
 }  // BrowserDB Constructor
     OnFillSqlTyp();
     OnFilldbTyp();
 }  // BrowserDB Constructor
@@ -126,13 +126,13 @@ bool BrowserDB::OnStartDB(int Quiet)
     // Connect to datasource
     //---------------------------------------------------------------------------------------
     DlgUser *p_Dlg;
     // Connect to datasource
     //---------------------------------------------------------------------------------------
     DlgUser *p_Dlg;
-    p_Dlg = new DlgUser(pDoc->p_MainFrame,pDoc,_T(""));
+    p_Dlg = new DlgUser(pDoc->p_MainFrame,pDoc,wxEmptyString);
     p_Dlg->s_DSN      = ODBCSource;
     p_Dlg->s_User     = UserName;
     p_Dlg->s_Password = Password;
     p_Dlg->OnInit();
     p_Dlg->Fit();
     p_Dlg->s_DSN      = ODBCSource;
     p_Dlg->s_User     = UserName;
     p_Dlg->s_Password = Password;
     p_Dlg->OnInit();
     p_Dlg->Fit();
-    
+
     bool OK = false;
     if (p_Dlg->ShowModal() == wxID_OK)
     {
     bool OK = false;
     if (p_Dlg->ShowModal() == wxID_OK)
     {
@@ -153,9 +153,9 @@ bool BrowserDB::OnStartDB(int Quiet)
         // wxLogMessage(">>>%s<<<>>>%s<<<",UserName.c_str(),Password.c_str());
         if (db_BrowserDB == NULL)
         {
         // wxLogMessage(">>>%s<<<>>>%s<<<",UserName.c_str(),Password.c_str());
         if (db_BrowserDB == NULL)
         {
-            DbConnectInf.SetDsn(wxT(""));
-            DbConnectInf.SetUserID(wxT(""));
-            DbConnectInf.SetPassword(wxT(""));
+            DbConnectInf.SetDsn(wxEmptyString);
+            DbConnectInf.SetUserID(wxEmptyString);
+            DbConnectInf.SetPassword(wxEmptyString);
             if (!Quiet)
             {
                 wxLogMessage(_("\n-E-> BrowserDB::OnConnectDataSource() DB CONNECTION ERROR : Unable to connect to the data source.\n\nCheck the name of your data source to verify it has been correctly entered/spelled.\n\nWith some databases, the user name and password must\nbe created with full rights to the table prior to making a connection\n(using tools provided by the database manufacturer)"));
             if (!Quiet)
             {
                 wxLogMessage(_("\n-E-> BrowserDB::OnConnectDataSource() DB CONNECTION ERROR : Unable to connect to the data source.\n\nCheck the name of your data source to verify it has been correctly entered/spelled.\n\nWith some databases, the user name and password must\nbe created with full rights to the table prior to making a connection\n(using tools provided by the database manufacturer)"));
@@ -251,8 +251,8 @@ bool BrowserDB::OnGetNext(int Cols,int WXUNUSED(Quiet))
             switch(i_dbDataType)
             {
             case DB_DATA_TYPE_VARCHAR:
             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))
+                wxStrcpy(s_temp,wxEmptyString);
+                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__);
                 {
                     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;
                 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__);
                 {
                     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;
                 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__);
                 {
                     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:
                 }
                 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__);
                 {
                     Temp0.Printf(_("\n-E-> BrowserDB::OnGetData - ODBC-Error with GetNext \n-E-> "));
                     Temp0 += GetExtendedDBErrorMsg(__TFILE__,__LINE__);
@@ -370,7 +376,7 @@ bool BrowserDB::OnSelect(wxString tb_Name, int Quiet)
         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_WXCHAR, sizeof(Name), true, true);  // Primary index
     //---------------------------------------------------------------------------------------
     if (!Quiet)
     {
     //---------------------------------------------------------------------------------------
     if (!Quiet)
     {
@@ -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)->pColFor->Format(1,
                                         (cl_BrowserDB+i)->dbDataType,
                                         (cl_BrowserDB+i)->sqlDataType,
-                                        (cl_BrowserDB+i)->columnSize, 
+                                        (cl_BrowserDB+i)->columnLength,
                                         (cl_BrowserDB+i)->decimalDigits);
     }
     return cl_BrowserDB;
                                         (cl_BrowserDB+i)->decimalDigits);
     }
     return cl_BrowserDB;
@@ -464,7 +470,7 @@ void BrowserDB::OnFillSqlTyp()
     i_SqlTyp[1]  = SQL_C_BINARY;    s_SqlTyp[1]  = _T("SQL_C_BINARY");
     i_SqlTyp[2]  = SQL_C_BIT;       s_SqlTyp[2]  = _T("SQL_C_BIT");
     i_SqlTyp[3]  = SQL_C_BOOKMARK;  s_SqlTyp[3]  = _T("SQL_C_BOOKMARK");
     i_SqlTyp[1]  = SQL_C_BINARY;    s_SqlTyp[1]  = _T("SQL_C_BINARY");
     i_SqlTyp[2]  = SQL_C_BIT;       s_SqlTyp[2]  = _T("SQL_C_BIT");
     i_SqlTyp[3]  = SQL_C_BOOKMARK;  s_SqlTyp[3]  = _T("SQL_C_BOOKMARK");
-    i_SqlTyp[4]  = SQL_C_CHAR;      s_SqlTyp[4]  = _T("SQL_C_CHAR");
+    i_SqlTyp[4]  = SQL_C_WXCHAR;    s_SqlTyp[4]  = _T("SQL_C_WXCHAR");
     i_SqlTyp[5]  = SQL_C_DATE;      s_SqlTyp[5]  = _T("SQL_C_DATE");
     i_SqlTyp[6]  = SQL_C_DEFAULT;   s_SqlTyp[6]  = _T("SQL_C_DEFAULT");
     i_SqlTyp[7]  = SQL_C_DOUBLE;    s_SqlTyp[7]  = _T("SQL_C_DOUBLE");
     i_SqlTyp[5]  = SQL_C_DATE;      s_SqlTyp[5]  = _T("SQL_C_DATE");
     i_SqlTyp[6]  = SQL_C_DEFAULT;   s_SqlTyp[6]  = _T("SQL_C_DEFAULT");
     i_SqlTyp[7]  = SQL_C_DOUBLE;    s_SqlTyp[7]  = _T("SQL_C_DOUBLE");
@@ -484,7 +490,7 @@ void BrowserDB::OnFillSqlTyp()
     i_SqlTyp[21] = SQL_NUMERIC;     s_SqlTyp[21] = _T("SQL_NUMERIC");
     i_SqlTyp[22] = SQL_LONGVARCHAR; s_SqlTyp[22] = _T("SQL_LONGVARCHAR");
     i_SqlTyp[23] = SQL_REAL;        s_SqlTyp[23] = _T("SQL_REAL");
     i_SqlTyp[21] = SQL_NUMERIC;     s_SqlTyp[21] = _T("SQL_NUMERIC");
     i_SqlTyp[22] = SQL_LONGVARCHAR; s_SqlTyp[22] = _T("SQL_LONGVARCHAR");
     i_SqlTyp[23] = SQL_REAL;        s_SqlTyp[23] = _T("SQL_REAL");
-    i_SqlTyp[0]  = 23;              s_SqlTyp[0]  = _T("");
+    i_SqlTyp[0]  = 23;              s_SqlTyp[0]  = wxEmptyString;
 }
 
 //----------------------------------------------------------------------------------------
 }
 
 //----------------------------------------------------------------------------------------
@@ -494,6 +500,6 @@ void BrowserDB::OnFilldbTyp()
     i_dbTyp[2] = DB_DATA_TYPE_INTEGER; s_dbTyp[2] = _T("DB_DATA_TYPE_INTEGER");
     i_dbTyp[3] = DB_DATA_TYPE_FLOAT;   s_dbTyp[3] = _T("DB_DATA_TYPE_FLOAT");
     i_dbTyp[4] = DB_DATA_TYPE_DATE;    s_dbTyp[4] = _T("DB_DATA_TYPE_DATE");
     i_dbTyp[2] = DB_DATA_TYPE_INTEGER; s_dbTyp[2] = _T("DB_DATA_TYPE_INTEGER");
     i_dbTyp[3] = DB_DATA_TYPE_FLOAT;   s_dbTyp[3] = _T("DB_DATA_TYPE_FLOAT");
     i_dbTyp[4] = DB_DATA_TYPE_DATE;    s_dbTyp[4] = _T("DB_DATA_TYPE_DATE");
-    i_dbTyp[0] = 4;                    s_dbTyp[0] = _T("");
+    i_dbTyp[0] = 4;                    s_dbTyp[0] = wxEmptyString;
 }
 //----------------------------------------------------------------------------------------
 }
 //----------------------------------------------------------------------------------------