X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2049ba38adafa0ec146880de29f26e32dd69a125..058939fc084207e06d34a2c82f4c62a103516dd8:/src/common/odbc.cpp diff --git a/src/common/odbc.cpp b/src/common/odbc.cpp index 67768ac38e..bdf71719d7 100644 --- a/src/common/odbc.cpp +++ b/src/common/odbc.cpp @@ -2,12 +2,12 @@ // Name: odbc.cpp // Purpose: ODBC implementation // Author: Julian Smart, Olaf Klein (oklein@smallo.ruhr.de), -// Patrick Halke (patrick@zaphod.ruhr.de) -// Modified by: +// Patrick Halke (patrick@zaphod.ruhr.de) +// Modified by: // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -23,7 +23,15 @@ #include "wx/defs.h" -#if USE_ODBC +// this code is old and shouldn't be used - use the new ODBC classes in db.cpp +// and dbtable.cpp instead +#define wxUSE_OLD_ODBC 0 + +#if wxUSE_OLD_ODBC + +#ifdef __VISUALC__ + #pragma warning(disable:4706) // assignment within conditional expression +#endif // VC++ #ifndef WX_PRECOMP #include "wx/utils.h" @@ -43,12 +51,10 @@ HENV wxDatabase::hEnv = 0; int wxDatabase::refCount = 0; -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxDatabase, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxQueryCol, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxQueryField, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxRecordSet, wxObject) -#endif wxDatabase::wxDatabase(void) { @@ -129,7 +135,8 @@ char* wxDatabase::GetErrorClass(void) { return sqlstate; } -bool wxDatabase::Open(char *thedatasource, bool exclusive, bool readOnly, char *username, char *password) +bool wxDatabase::Open(char *thedatasource, bool WXUNUSED(exclusive), + bool WXUNUSED(readOnly), char *username, char *password) { err_occured = FALSE; @@ -198,7 +205,7 @@ char *wxDatabase::GetDatabaseName(void) char nameBuf[400]; int nameSize = 0; - retcode = SQLGetInfo(hDBC, SQL_DATABASE_NAME, nameBuf, sizeof(nameBuf), (short *)&nameSize); + retcode = SQLGetInfo(hDBC, SQL_DATABASE_NAME, (unsigned char*)nameBuf, sizeof(nameBuf), (short *)&nameSize); if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO) return NULL; @@ -230,15 +237,15 @@ bool wxDatabase::InWaitForDataSource(void) return FALSE; } -void wxDatabase::SetLoginTimeout(long seconds) +void wxDatabase::SetLoginTimeout(long WXUNUSED(seconds)) { } -void wxDatabase::SetQueryTimeout(long seconds) +void wxDatabase::SetQueryTimeout(long WXUNUSED(seconds)) { } -void wxDatabase::SetSynchronousMode(bool synchronous) +void wxDatabase::SetSynchronousMode(bool WXUNUSED(synchronous)) { } @@ -263,11 +270,11 @@ void wxDatabase::Cancel(void) } // Overridables -void wxDatabase::OnSetOptions(wxRecordSet *recordSet) +void wxDatabase::OnSetOptions(wxRecordSet *WXUNUSED(recordSet)) { } -void wxDatabase::OnWaitForDataSource(bool stillExecuting) +void wxDatabase::OnWaitForDataSource(bool WXUNUSED(stillExecuting)) { } @@ -335,7 +342,7 @@ void wxDatabase::ResetRecordSets(void) bool wxDatabase::GetInfo(long infoType, long *buf) { short sz = 0; - retcode = SQLGetInfo(hDBC, (UWORD)infoType, (char *)buf, sizeof(buf), &sz); + retcode = SQLGetInfo(hDBC, (UWORD)infoType, (unsigned char*)buf, sizeof(buf), &sz); if (retcode != SQL_ERROR) return TRUE; @@ -349,7 +356,7 @@ bool wxDatabase::GetInfo(long infoType, char *buf, int bufSize) bufSize = sizeof(buf); short sz = 0; - retcode = SQLGetInfo(hDBC, (UWORD)infoType, buf, bufSize, &sz); + retcode = SQLGetInfo(hDBC, (UWORD)infoType, (unsigned char*)buf, bufSize, &sz); if (retcode != SQL_ERROR) return TRUE; @@ -386,7 +393,7 @@ wxString wxDatabase::GetODBCVersionString(bool implementation) int bufSize = sizeof(buf); short sz = 0; - retcode = SQLGetInfo(hDBC, (UWORD)SQL_ODBC_VER, buf, bufSize, &sz); + retcode = SQLGetInfo(hDBC, (UWORD)SQL_ODBC_VER, (unsigned char*)buf, bufSize, &sz); if (hDBC != 0 && noDBC) { @@ -427,7 +434,7 @@ float wxDatabase::GetODBCVersionFloat(bool implementation) int bufSize = sizeof(buf); short sz = 0; - retcode = SQLGetInfo(hDBC, (UWORD)SQL_ODBC_VER, buf, bufSize, &sz); + retcode = SQLGetInfo(hDBC, (UWORD)SQL_ODBC_VER, (unsigned char*)buf, bufSize, &sz); if (hDBC != 0 && noDBC) { @@ -438,7 +445,7 @@ float wxDatabase::GetODBCVersionFloat(bool implementation) if (retcode == SQL_ERROR) return 0.0; else - return atof(buf); + return (float)atof(buf); } /* @@ -485,7 +492,7 @@ wxRecordSet::~wxRecordSet(void) } // If SQL is non-NULL, table and columns can be NULL. -bool wxRecordSet::BeginQuery(int openType, char *sql, int options) +bool wxRecordSet::BeginQuery(int WXUNUSED(openType), char *WXUNUSED(sql), int WXUNUSED(options)) { // Needs to construct an appropriate SQL statement. By default // (i.e. if table and columns are provided) then @@ -565,7 +572,7 @@ void wxRecordSet::FillVars(int recnum) { do { ((wxQueryCol*)node->Data())->FillVar(recnum); - } while (node = node->Next()); + } while ((node = node->Next())); } bool wxRecordSet::GetResultSet(void) @@ -606,14 +613,14 @@ bool wxRecordSet::GetResultSet(void) curcol = cols.Append(name, col1); col1->SetName(name); col1->SetType(type); - col1->SetNullable(nullable); + col1->SetNullable((nullable != 0)); wxQueryField *field1 = new wxQueryField; fetch = fetchbuf.Append(field1); field1->SetType(type); field1->SetSize(len); - SQLBindCol(hStmt, i+1, SQL_C_BINARY, field1->GetData(), field1->GetSize(), &trash); + SQLBindCol(hStmt, i+1, SQL_C_BINARY, (unsigned char*)field1->GetData(), field1->GetSize(), &trash); } switch (type) { @@ -796,7 +803,7 @@ bool wxRecordSet::GetTables(void) bool wxRecordSet::GetColumns(char* table) { char* name=NULL; - char* wildcard = "%"; +// char* wildcard = "%"; name = table ? table : tablename; @@ -836,7 +843,7 @@ bool wxRecordSet::GetColumns(char* table) bool wxRecordSet::GetPrimaryKeys(char* table) { char* name=NULL; - char* wildcard = "%"; +// char* wildcard = "%"; name = table ? table : tablename; @@ -875,7 +882,7 @@ bool wxRecordSet::GetForeignKeys(char* PkTableName, char * FkTableName) { char* Pkname=NULL; char* Fkname=NULL; - char* wildcard = "%"; +// char* wildcard = "%"; // Try to disable situation: both PkTableName and FkTableName are NULL // set Pkname from tablename @@ -1371,7 +1378,7 @@ void wxRecordSet::SetFieldDirty(const char* name, bool dirty) ((wxQueryCol*)node->Data())->SetFieldDirty(cursor, dirty); } -void wxRecordSet::SetFieldNull(void *p, bool isNull) +void wxRecordSet::SetFieldNull(void *WXUNUSED(p), bool WXUNUSED(isNull)) { } @@ -1534,7 +1541,7 @@ long wxQueryCol::GetSize(int row) { wxNode* node = fields.Nth(row); if (!node) - return NULL; + return 0; return ((wxQueryField*)node->Data())->GetSize(); } @@ -1599,7 +1606,7 @@ bool wxQueryField::AllocData(void) { { if (data) // JACS delete[] (char*)data; - if (data = new char[size+1]) + if ((data = new char[size+1])) { char *str = (char *)data; int i; @@ -1613,7 +1620,7 @@ bool wxQueryField::AllocData(void) { { if (data) // JACS delete (long*)data; - if (data = new long) + if ((data = new long)) *(long*)data = 0L; break; } @@ -1621,7 +1628,7 @@ bool wxQueryField::AllocData(void) { { if (data) delete (short*)data; - if (data = new short) + if ((data = new short)) *(short*)data = 0; break; } @@ -1630,7 +1637,7 @@ bool wxQueryField::AllocData(void) { { if (data) delete (double*)data; - if (data = new double) + if ((data = new double)) *(double*)data = 0; break; } @@ -1638,7 +1645,7 @@ bool wxQueryField::AllocData(void) { { if (data) delete (float*)data; - if (data = new float) + if ((data = new float)) *(float*)data = (float)0; break; } @@ -1826,4 +1833,8 @@ bool wxQueryField::IsDirty(void) { return dirty; } -#endif // USE_ODBC +#ifdef __VISUALC__ + #pragma warning(default:4706) // assignment within conditional expression +#endif // VC++ + +#endif // wxUSE_OLD_ODBC