merged 2.2 branch

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@7748 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Bryan Petty
2000-07-15 19:51:35 +00:00
parent 8a693e6e04
commit f6bcfd974e
1835 changed files with 237729 additions and 67990 deletions

View File

@@ -16,7 +16,7 @@
donated by the development team at Remstar International.
The table this sample is based on is developer contact table, and shows
some of the simple uses of the database classes wxDB and wxTable.
some of the simple uses of the database classes wxDb and wxDbTable.
* SYNOPSIS END
*/
@@ -42,7 +42,7 @@
#include <stdio.h> /* Included strictly for reading the text file with the database parameters */
#include <wx/db.h> /* Required in the file which will get the data source connection */
#include <wx/dbtable.h> /* Has the wxTable object from which all data objects will inherit their data table functionality */
#include <wx/dbtable.h> /* Has the wxDbTable object from which all data objects will inherit their data table functionality */
extern wxDbList WXDLLEXPORT *PtrBegDbList; /* from db.cpp, used in getting back error results from db connections */
@@ -61,23 +61,23 @@ DatabaseDemoFrame *DemoFrame; /* Pointer to the main frame */
* for user login names and passwords, getting workstation settings, etc.
* ---> IMPORTANT <---
*
* For each database object created which uses this wxDB pointer
* For each database object created which uses this wxDb pointer
* connection to the database, when a CommitTrans() or RollBackTrans()
* will commit or rollback EVERY object which uses this wxDB pointer.
* will commit or rollback EVERY object which uses this wxDb pointer.
*
* To allow each table object (those derived from wxTable) to be
* To allow each table object (those derived from wxDbTable) to be
* individually committed or rolled back, you MUST use a different
* instance of wxDB in the constructor of the table. Doing so creates
* instance of wxDb in the constructor of the table. Doing so creates
* more overhead, and will use more database connections (some DBs have
* connection limits...), so use connections sparringly.
*
* It is recommended that one "main" database connection be created for
* the entire program to use for READ-ONLY database accesses, but for each
* table object which will do a CommitTrans() or RollbackTrans() that a
* new wxDB object be created and used for it.
* new wxDb object be created and used for it.
*/
wxDB *READONLY_DB;
wxDb *READONLY_DB;
/*
* This function will return the exact string(s) from the database engine
@@ -103,7 +103,7 @@ char *GetExtendedDBErrorMsg(char *ErrFile, int ErrLine)
msg += ErrFile;
msg += " Line: ";
tStr.Printf("%d",ErrLine);
msg += tStr.GetData();
msg += tStr.c_str();
msg += "\n";
}
@@ -125,7 +125,7 @@ char *GetExtendedDBErrorMsg(char *ErrFile, int ErrLine)
if (pDbList->PtrDb->errorList[i])
{
msg.Append(pDbList->PtrDb->errorList[i]);
if (strcmp(pDbList->PtrDb->errorList[i],"") != 0)
if (wxStrcmp(pDbList->PtrDb->errorList[i],"") != 0)
msg.Append("\n");
}
}
@@ -187,37 +187,37 @@ bool DatabaseDemoApp::OnInit()
char buffer[1000+1];
fgets(buffer, sizeof(params.ODBCSource), paramFile);
buffer[strlen(buffer)-1] = '\0';
strcpy(params.ODBCSource,buffer);
buffer[wxStrlen(buffer)-1] = '\0';
wxStrcpy(params.ODBCSource,buffer);
fgets(buffer, sizeof(params.UserName), paramFile);
buffer[strlen(buffer)-1] = '\0';
strcpy(params.UserName,buffer);
buffer[wxStrlen(buffer)-1] = '\0';
wxStrcpy(params.UserName,buffer);
fgets(buffer, sizeof(params.Password), paramFile);
buffer[strlen(buffer)-1] = '\0';
strcpy(params.Password,buffer);
buffer[wxStrlen(buffer)-1] = '\0';
wxStrcpy(params.Password,buffer);
fgets(buffer, sizeof(params.DirPath), paramFile);
buffer[strlen(buffer)-1] = '\0';
strcpy(params.DirPath,buffer);
buffer[wxStrlen(buffer)-1] = '\0';
wxStrcpy(params.DirPath,buffer);
fclose(paramFile);
// Connect to datasource
strcpy(DbConnectInf.Dsn, params.ODBCSource); // ODBC data source name (created with ODBC Administrator under Win95/NT)
strcpy(DbConnectInf.Uid, params.UserName); // database username - must already exist in the data source
strcpy(DbConnectInf.AuthStr, params.Password); // password database username
strcpy(DbConnectInf.defaultDir, params.DirPath); // path where the table exists (needed for dBase)
wxStrcpy(DbConnectInf.Dsn, params.ODBCSource); // ODBC data source name (created with ODBC Administrator under Win95/NT)
wxStrcpy(DbConnectInf.Uid, params.UserName); // database username - must already exist in the data source
wxStrcpy(DbConnectInf.AuthStr, params.Password); // password database username
wxStrcpy(DbConnectInf.defaultDir, params.DirPath); // path where the table exists (needed for dBase)
READONLY_DB = wxDbGetConnection(&DbConnectInf);
if (READONLY_DB == 0)
{
wxMessageBox("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 CONTACT table prior to making a connection\n(using tools provided by the database manufacturer)", "DB CONNECTION ERROR...",wxOK | wxICON_EXCLAMATION);
DemoFrame->BuildParameterDialog(NULL);
strcpy(DbConnectInf.Dsn, "");
strcpy(DbConnectInf.Uid, "");
strcpy(DbConnectInf.AuthStr, "");
wxStrcpy(DbConnectInf.Dsn, "");
wxStrcpy(DbConnectInf.Uid, "");
wxStrcpy(DbConnectInf.AuthStr, "");
wxMessageBox("Now exiting program.\n\nRestart program to try any new settings.","Notice...",wxOK | wxICON_INFORMATION);
return(FALSE);
}
@@ -278,7 +278,13 @@ void DatabaseDemoFrame::OnCloseWindow(wxCloseEvent& event)
if (pEditorDlg->Close())
pEditorDlg = NULL;
else
{
event.Veto();
return;
}
// Cleans up the environment space allocated for the SQL/ODBC connection handle
SQLFreeEnv(DbConnectInf.Henv);
this->Destroy();
@@ -353,24 +359,24 @@ void DatabaseDemoFrame::BuildParameterDialog(wxWindow *parent)
/*
* Constructor note: If no wxDB object is passed in, a new connection to the database
* Constructor note: If no wxDb object is passed in, a new connection to the database
* is created for this instance of Ccontact. This can be a slow process depending
* on the database engine being used, and some database engines have a limit on the
* number of connections (either hard limits, or license restricted) so care should
* be used to use as few connections as is necessary.
*
* IMPORTANT: Objects which share a wxDB pointer are ALL acted upon whenever a member
* IMPORTANT: Objects which share a wxDb pointer are ALL acted upon whenever a member
* function of pDb is called (i.e. CommitTrans() or RollbackTrans(), so if modifying
* or creating a table objects which use the same pDb, know that all the objects
* will be committed or rolled back when any of the objects has this function call made.
*/
Ccontact::Ccontact (wxDB *pwxDB) : wxTable(pwxDB ? pwxDB : wxDbGetConnection(&DbConnectInf),CONTACT_TABLE_NAME,CONTACT_NO_COLS,NULL,!QUERY_ONLY,DbConnectInf.defaultDir)
Ccontact::Ccontact (wxDb *pwxDb) : wxDbTable(pwxDb ? pwxDb : wxDbGetConnection(&DbConnectInf),CONTACT_TABLE_NAME,CONTACT_NO_COLS,NULL,!wxDB_QUERY_ONLY,DbConnectInf.defaultDir)
{
// This is used to represent whether the database connection should be released
// when this instance of the object is deleted. If using the same connection
// for multiple instance of database objects, then the connection should only be
// released when the last database instance using the connection is deleted
freeDbConn = !pwxDB;
freeDbConn = !pwxDb;
SetupColumns();
@@ -404,7 +410,7 @@ Ccontact::~Ccontact()
{
if (freeDbConn)
{
if (!wxDbFreeConnection(pDb))
if (!wxDbFreeConnection(GetDb()))
{
wxString tStr;
tStr = "Unable to Free the Ccontact data table handle\n\n";
@@ -416,7 +422,7 @@ Ccontact::~Ccontact()
/*
* Handles setting up all the connections for the interface from the wxTable
* Handles setting up all the connections for the interface from the wxDbTable
* functions to interface to the data structure used to store records in
* memory, and for all the column definitions that define the table structure
*/
@@ -444,19 +450,19 @@ bool Ccontact::CreateIndexes(void)
// This index could easily be accomplished with an "orderBy" clause,
// but is done to show how to construct a non-primary index.
wxString indexName;
CidxDef idxDef[2];
wxDbIdxDef idxDef[2];
bool Ok = TRUE;
strcpy(idxDef[0].ColName, "IS_DEV");
wxStrcpy(idxDef[0].ColName, "IS_DEV");
idxDef[0].Ascending = TRUE;
strcpy(idxDef[1].ColName, "NAME");
wxStrcpy(idxDef[1].ColName, "NAME");
idxDef[1].Ascending = TRUE;
indexName = CONTACT_TABLE_NAME;
indexName = GetTableName();
indexName += "_IDX1";
Ok = CreateIndex((char*) (const char*) indexName, TRUE, 2, idxDef);
Ok = CreateIndex(indexName.c_str(), TRUE, 2, idxDef);
return Ok;
} // Ccontact::CreateIndexes()
@@ -470,8 +476,8 @@ bool Ccontact::CreateIndexes(void)
bool Ccontact::FetchByName(char *name)
{
whereStr.Printf("NAME = '%s'",name);
where = (char*) (const char*) this->whereStr;
orderBy = 0;
SetWhereClause(whereStr.c_str());
SetOrderByClause("");
if (!Query())
return(FALSE);
@@ -523,7 +529,7 @@ CeditorDlg::CeditorDlg(wxWindow *parent) : wxPanel (parent, 1, 1, 460, 455)
// Check if the table exists or not. If it doesn't, ask the user if they want to
// create the table. Continue trying to create the table until it exists, or user aborts
while (!Contact->pDb->TableExists((char *)CONTACT_TABLE_NAME,DbConnectInf.Uid,DbConnectInf.defaultDir))
while (!Contact->GetDb()->TableExists((char *)CONTACT_TABLE_NAME,DbConnectInf.Uid,DbConnectInf.defaultDir))
{
wxString tStr;
tStr.Printf("Unable to open the table '%s'.\n\nTable may need to be created...?\n\n",CONTACT_TABLE_NAME);
@@ -549,7 +555,7 @@ CeditorDlg::CeditorDlg(wxWindow *parent) : wxPanel (parent, 1, 1, 460, 455)
// Table does exist, there was some problem opening it. Currently this should
// never fail, except in the case of the table not exisiting. Open() basically
// only sets up variable/pointer values, other than checking for table existence.
if (Contact->pDb->TableExists((char *)CONTACT_TABLE_NAME))
if (Contact->GetDb()->TableExists((char *)CONTACT_TABLE_NAME))
{
wxString tStr;
tStr.Printf("Unable to open the table '%s'.\n\n",CONTACT_TABLE_NAME);
@@ -622,24 +628,24 @@ CeditorDlg::CeditorDlg(wxWindow *parent) : wxPanel (parent, 1, 1, 460, 455)
// as there will only be one record being shown on the dialog at a time, this optimizes
// network traffic by only returning a one row result
Contact->orderBy = "NAME"; // field name to sort by
Contact->SetOrderByClause("NAME"); // field name to sort by
// The wxString "whereStr" is not a member of the wxTable object, it is a member variable
// The wxString "whereStr" is not a member of the wxDbTable object, it is a member variable
// specifically in the Ccontact class. It is used here for simpler construction of a varying
// length string, and then after the string is built, the wxTable member variable "where" is
// length string, and then after the string is built, the wxDbTable member variable "where" is
// assigned the pointer to the constructed string.
//
// The constructed where clause below has a sub-query within it "SELECT MIN(NAME) FROM %s"
// to achieve a single row (in this case the first name in alphabetical order).
if (Contact->pDb->Dbms() != dbmsPOSTGRES)
if (Contact->GetDb()->Dbms() != dbmsPOSTGRES)
{
Contact->whereStr.sprintf("NAME = (SELECT MIN(NAME) FROM %s)",Contact->tableName);
Contact->whereStr.sprintf("NAME = (SELECT MIN(NAME) FROM %s)",Contact->GetTableName());
// NOTE: (const char*) returns a pointer which may not be valid later, so this is short term use only
Contact->where = (char*) (const char*) Contact->whereStr;
Contact->SetWhereClause(Contact->whereStr.c_str());
}
else
Contact->where = 0;
Contact->SetWhereClause("");
// Perform the Query to get the result set.
// NOTE: If there are no rows returned, that is a valid result, so Query() would return TRUE.
@@ -743,7 +749,7 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
// of Ccontact is deleted. If the Commit wasn't performed, the
// database will automatically Rollback the changes when the database
// connection is terminated
Contact->pDb->CommitTrans();
Contact->GetDb()->CommitTrans();
// Try to get the row that followed the just deleted row in the orderBy sequence
if (!GetNextRec())
@@ -761,7 +767,7 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
}
else
// Delete failed
Contact->pDb->RollbackTrans();
Contact->GetDb()->RollbackTrans();
SetMode(mView);
return;
@@ -780,7 +786,7 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
if (!Ok)
return;
if (!strcmp((const char*) saveName,""))
if (!wxStrcmp((const char*) saveName,""))
{
Contact->Initialize();
PutData();
@@ -799,15 +805,15 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
}
// Previous record not available, retrieve first record in table
if (Contact->pDb->Dbms() != dbmsPOSTGRES)
if (Contact->GetDb()->Dbms() != dbmsPOSTGRES)
{
Contact->whereStr = "NAME = (SELECT MIN(NAME) FROM ";
Contact->whereStr += Contact->tableName;
Contact->whereStr += Contact->GetTableName();
Contact->whereStr += ")";
Contact->where = (char*) (const char*) Contact->whereStr;
Contact->SetWhereClause(Contact->whereStr.c_str());
}
else
Contact->where = 0;
Contact->SetWhereClause("");
if (!Contact->Query())
{
@@ -849,19 +855,19 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
{
// Display the query dialog box
char qryWhere[DB_MAX_WHERE_CLAUSE_LEN+1];
strcpy(qryWhere, (const char*) Contact->qryWhereStr);
wxStrcpy(qryWhere, (const char*) Contact->qryWhereStr);
char *tblName[] = {(char *)CONTACT_TABLE_NAME, 0};
new CqueryDlg(GetParent(), Contact->pDb, tblName, qryWhere);
new CqueryDlg(GetParent(), Contact->GetDb(), tblName, qryWhere);
// Query the first record in the new record set and
// display it, if the query string has changed.
if (strcmp(qryWhere, (const char*) Contact->qryWhereStr))
if (wxStrcmp(qryWhere, (const char*) Contact->qryWhereStr))
{
Contact->whereStr = "";
Contact->orderBy = "NAME";
Contact->SetOrderByClause("NAME");
if (Contact->pDb->Dbms() != dbmsPOSTGRES)
if (Contact->GetDb()->Dbms() != dbmsPOSTGRES)
{
Contact->whereStr = "NAME = (SELECT MIN(NAME) FROM ";
Contact->whereStr += CONTACT_TABLE_NAME;
@@ -869,7 +875,7 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
// Append the query where string (if there is one)
Contact->qryWhereStr = qryWhere;
if (strlen(qryWhere))
if (wxStrlen(qryWhere))
{
Contact->whereStr += " WHERE ";
Contact->whereStr += Contact->qryWhereStr;
@@ -877,7 +883,7 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
// Close the expression with a right paren
Contact->whereStr += ")";
// Requery the table
Contact->where = (char*) (const char*) Contact->whereStr;
Contact->SetWhereClause(Contact->whereStr.c_str());
if (!Contact->Query())
{
wxString tStr;
@@ -903,16 +909,16 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
{
// Clear the additional where criteria established by the query feature
Contact->qryWhereStr = "";
Contact->orderBy = "NAME";
Contact->SetOrderByClause("NAME");
if (Contact->pDb->Dbms() != dbmsPOSTGRES)
if (Contact->GetDb()->Dbms() != dbmsPOSTGRES)
{
Contact->whereStr = "NAME = (SELECT MIN(NAME) FROM ";
Contact->whereStr += CONTACT_TABLE_NAME;
Contact->whereStr += ")";
}
Contact->where = (char*) (const char*) Contact->whereStr;
Contact->SetWhereClause(Contact->whereStr.c_str());
if (!Contact->Query())
{
wxString tStr;
@@ -941,7 +947,7 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
/* char *orderBy */ "NAME",
/* bool distinctValues */ TRUE);
if (ListDB_Selection && strlen(ListDB_Selection))
if (ListDB_Selection && wxStrlen(ListDB_Selection))
{
wxString w = "NAME = '";
w += ListDB_Selection;
@@ -996,9 +1002,9 @@ void CeditorDlg::SetMode(enum DialogModes m)
if (widgetPtrsSet)
{
pCreateBtn->Enable( !edit );
pEditBtn->Enable( !edit && (strcmp(Contact->Name,"")!=0) );
pDeleteBtn->Enable( !edit && (strcmp(Contact->Name,"")!=0) );
pCopyBtn->Enable( !edit && (strcmp(Contact->Name,"")!=0) );
pEditBtn->Enable( !edit && (wxStrcmp(Contact->Name,"")!=0) );
pDeleteBtn->Enable( !edit && (wxStrcmp(Contact->Name,"")!=0) );
pCopyBtn->Enable( !edit && (wxStrcmp(Contact->Name,"")!=0) );
pSaveBtn->Enable( edit );
pCancelBtn->Enable( edit );
pPrevBtn->Enable( !edit );
@@ -1055,7 +1061,7 @@ bool CeditorDlg::GetData()
wxString tStr;
tStr = pNameTxt->GetValue();
if (!strcmp((const char*) tStr,""))
if (!wxStrcmp((const char*) tStr,""))
{
wxMessageBox("A name is required for entry into the contact table","Notice...",wxOK | wxICON_INFORMATION);
return FALSE;
@@ -1127,13 +1133,13 @@ bool CeditorDlg::GetData()
}
tStr = pNameTxt->GetValue();
strcpy(Contact->Name,(const char*) tStr);
strcpy(Contact->Addr1,pAddress1Txt->GetValue());
strcpy(Contact->Addr2,pAddress2Txt->GetValue());
strcpy(Contact->City,pCityTxt->GetValue());
strcpy(Contact->State,pStateTxt->GetValue());
strcpy(Contact->Country,pCountryTxt->GetValue());
strcpy(Contact->PostalCode,pPostalCodeTxt->GetValue());
wxStrcpy(Contact->Name,(const char*) tStr);
wxStrcpy(Contact->Addr1,pAddress1Txt->GetValue());
wxStrcpy(Contact->Addr2,pAddress2Txt->GetValue());
wxStrcpy(Contact->City,pCityTxt->GetValue());
wxStrcpy(Contact->State,pStateTxt->GetValue());
wxStrcpy(Contact->Country,pCountryTxt->GetValue());
wxStrcpy(Contact->PostalCode,pPostalCodeTxt->GetValue());
Contact->Contributions = atoi(pContribTxt->GetValue());
Contact->LinesOfCode = atol(pLinesTxt->GetValue());
@@ -1207,11 +1213,11 @@ bool CeditorDlg::Save()
if (!failed)
{
Contact->pDb->CommitTrans();
Contact->GetDb()->CommitTrans();
SetMode(mView); // Sets the dialog mode back to viewing after save is successful
}
else
Contact->pDb->RollbackTrans();
Contact->GetDb()->RollbackTrans();
wxEndBusyCursor();
}
@@ -1229,10 +1235,10 @@ bool CeditorDlg::GetNextRec()
{
wxString w;
if (Contact->pDb->Dbms() != dbmsPOSTGRES)
if (Contact->GetDb()->Dbms() != dbmsPOSTGRES)
{
w = "NAME = (SELECT MIN(NAME) FROM ";
w += Contact->tableName;
w += Contact->GetTableName();
w += " WHERE NAME > '";
}
else
@@ -1264,10 +1270,10 @@ bool CeditorDlg::GetPrevRec()
{
wxString w;
if (Contact->pDb->Dbms() != dbmsPOSTGRES)
if (Contact->GetDb()->Dbms() != dbmsPOSTGRES)
{
w = "NAME = (SELECT MAX(NAME) FROM ";
w += Contact->tableName;
w += Contact->GetTableName();
w += " WHERE NAME < '";
}
else
@@ -1297,8 +1303,8 @@ bool CeditorDlg::GetPrevRec()
*/
bool CeditorDlg::GetRec(char *whereStr)
{
Contact->where = whereStr;
Contact->orderBy = "NAME";
Contact->SetWhereClause(whereStr);
Contact->SetOrderByClause("NAME");
if (!Contact->Query())
{
@@ -1452,7 +1458,7 @@ bool CparameterDlg::GetData()
wxMessageBox(errmsg,"Internal program error...",wxOK | wxICON_EXCLAMATION);
return FALSE;
}
strcpy(wxGetApp().params.ODBCSource, tStr);
wxStrcpy(wxGetApp().params.ODBCSource, tStr);
}
else
return FALSE;
@@ -1465,7 +1471,7 @@ bool CparameterDlg::GetData()
wxMessageBox(errmsg,"Internal program error...",wxOK | wxICON_EXCLAMATION);
return FALSE;
}
strcpy(wxGetApp().params.UserName, tStr);
wxStrcpy(wxGetApp().params.UserName, tStr);
tStr = pParamPasswordTxt->GetValue();
if (tStr.Length() > (sizeof(wxGetApp().params.Password)-1))
@@ -1475,7 +1481,7 @@ bool CparameterDlg::GetData()
wxMessageBox(errmsg,"Internal program error...",wxOK | wxICON_EXCLAMATION);
return FALSE;
}
strcpy(wxGetApp().params.Password,tStr);
wxStrcpy(wxGetApp().params.Password,tStr);
tStr = pParamDirPathTxt->GetValue();
tStr.Replace("\\","/");
@@ -1486,7 +1492,7 @@ bool CparameterDlg::GetData()
wxMessageBox(errmsg,"Internal program error...",wxOK | wxICON_EXCLAMATION);
return FALSE;
}
strcpy(wxGetApp().params.DirPath,tStr);
wxStrcpy(wxGetApp().params.DirPath,tStr);
return TRUE;
} // CparameterDlg::GetData()
@@ -1537,7 +1543,7 @@ void CparameterDlg::FillDataSourceList()
char **p = strList.ListToArray();
int i;
for (i = 0; strlen(p[i]); i++)
for (i = 0; wxStrlen(p[i]); i++)
pParamODBCSourceList->Append(p[i]);
} // CparameterDlg::CparameterDlg::FillDataSourceList()
@@ -1548,7 +1554,7 @@ BEGIN_EVENT_TABLE(CqueryDlg, wxDialog)
END_EVENT_TABLE()
// CqueryDlg() constructor
CqueryDlg::CqueryDlg(wxWindow *parent, wxDB *pDb, char *tblName[], char *pWhereArg) : wxDialog (parent, QUERY_DIALOG, "Query", wxPoint(-1, -1), wxSize(480, 360))
CqueryDlg::CqueryDlg(wxWindow *parent, wxDb *pDb, char *tblName[], char *pWhereArg) : wxDialog (parent, QUERY_DIALOG, "Query", wxPoint(-1, -1), wxSize(480, 360))
{
wxBeginBusyCursor();
@@ -1560,7 +1566,7 @@ CqueryDlg::CqueryDlg(wxWindow *parent, wxDB *pDb, char *tblName[], char *pWhereA
// Initialize the WHERE clause from the string passed in
pWhere = pWhereArg; // Save a pointer to the output buffer
if (strlen(pWhere) > DB_MAX_WHERE_CLAUSE_LEN) // Check the length of the buffer passed in
if (wxStrlen(pWhere) > DB_MAX_WHERE_CLAUSE_LEN) // Check the length of the buffer passed in
{
wxString s;
s.Printf("Maximum where clause length exceeded.\nLength must be less than %d", DB_MAX_WHERE_CLAUSE_LEN+1);
@@ -1623,11 +1629,11 @@ CqueryDlg::CqueryDlg(wxWindow *parent, wxDB *pDb, char *tblName[], char *pWhereA
}
int i;
for (i = 0; colInf[i].colName && strlen(colInf[i].colName); i++)
for (i = 0; colInf[i].colName && wxStrlen(colInf[i].colName); i++)
{
// If there is more than one table being queried, qualify
// the column names with the table name prefix.
if (tblName[1] && strlen(tblName[1]))
if (tblName[1] && wxStrlen(tblName[1]))
{
qualName.Printf("%s.%s", colInf[i].tableName, colInf[i].colName);
pQueryCol1Choice->Append(qualName);
@@ -1842,7 +1848,7 @@ void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
if (widgetName == pQueryDoneBtn->GetName())
{
// Be sure the where clause will not overflow the output buffer
if (strlen(pQuerySqlWhereMtxt->GetValue()) > DB_MAX_WHERE_CLAUSE_LEN)
if (wxStrlen(pQuerySqlWhereMtxt->GetValue()) > DB_MAX_WHERE_CLAUSE_LEN)
{
wxString s;
s.Printf("Maximum where clause length exceeded.\nLength must be less than %d", DB_MAX_WHERE_CLAUSE_LEN+1);
@@ -1853,7 +1859,7 @@ void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
if (!ValidateWhereClause())
return;
// Copy the where clause to the output buffer and exit
strcpy(pWhere, pQuerySqlWhereMtxt->GetValue());
wxStrcpy(pWhere, pQuerySqlWhereMtxt->GetValue());
Close();
return;
@@ -1902,7 +1908,7 @@ void CqueryDlg::OnCloseWindow(wxCloseEvent& event)
while (wxIsBusy())
wxEndBusyCursor();
Show(FALSE);
Show(FALSE);
this->Destroy();
} // CqueryDlg::OnCloseWindow()
@@ -1925,7 +1931,7 @@ void CqueryDlg::ProcessAddBtn()
if (pQueryCol2Choice->GetSelection() == 0) // "Value" is selected
{
// Verify that value 1 is filled in
if (strlen(pQueryValue1Txt->GetValue()) == 0)
if (wxStrlen(pQueryValue1Txt->GetValue()) == 0)
{
wxBell();
pQueryValue1Txt->SetFocus();
@@ -1933,7 +1939,7 @@ void CqueryDlg::ProcessAddBtn()
}
// For the BETWEEN operator, value 2 must be filled in as well
if (oper == qryOpBETWEEN &&
strlen(pQueryValue2Txt->GetValue()) == 0)
wxStrlen(pQueryValue2Txt->GetValue()) == 0)
{
wxBell();
pQueryValue2Txt->SetFocus();
@@ -2023,11 +2029,11 @@ void CqueryDlg::ProcessCountBtn()
if (!ValidateWhereClause())
return;
if (dbTable == 0) // wxTable object needs to be created and opened
if (dbTable == 0) // wxDbTable object needs to be created and opened
{
if (!(dbTable = new wxTable(pDB, masterTableName, 0, NULL, !QUERY_ONLY, DbConnectInf.defaultDir)))
if (!(dbTable = new wxDbTable(pDB, masterTableName, 0, NULL, !wxDB_QUERY_ONLY, DbConnectInf.defaultDir)))
{
wxMessageBox("Memory allocation failed creating a wxTable object.","Error...",wxOK | wxICON_EXCLAMATION);
wxMessageBox("Memory allocation failed creating a wxDbTable object.","Error...",wxOK | wxICON_EXCLAMATION);
return;
}
if (!dbTable->Open())
@@ -2041,14 +2047,14 @@ void CqueryDlg::ProcessCountBtn()
}
// Count() with WHERE clause
wxString whereStr;
wxString whereStr;
whereStr = pQuerySqlWhereMtxt->GetValue();
dbTable->where = (char *)whereStr.GetData();
dbTable->SetWhereClause(whereStr.c_str());
ULONG whereCnt = dbTable->Count();
// Count() of all records in the table
dbTable->where = 0;
dbTable->SetWhereClause("");
ULONG totalCnt = dbTable->Count();
if (whereCnt > 0 || totalCnt == 0)
@@ -2108,7 +2114,7 @@ bool CqueryDlg::ValidateWhereClause()
SQLInstallerError(1,&retcode,errMsg,500,&cb);
wxMessageBox("FAILED creating data source","FAILED");
wxMessageBox("FAILED creating data source","FAILED");
}
else
wxMessageBox("SUCCEEDED creating data source","SUCCESS");