fixed wxDB compilation
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45179 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -39,6 +39,13 @@
|
||||
|
||||
#include "wx/dbtable.h"
|
||||
|
||||
// FIXME-UTF8: get rid of this after switching to Unicode-only builds:
|
||||
#if wxUSE_UNICODE
|
||||
#define WXSQLCAST(s) ((SQLTCHAR FAR *)(wchar_t*)(s).wchar_str())
|
||||
#else
|
||||
#define WXSQLCAST(s) ((SQLTCHAR FAR *)(char*)(s).char_str())
|
||||
#endif
|
||||
|
||||
ULONG lastTableID = 0;
|
||||
|
||||
|
||||
@@ -615,7 +622,7 @@ bool wxDbTable::execDelete(const wxString &pSqlStmt)
|
||||
RETCODE retcode;
|
||||
|
||||
// Execute the DELETE statement
|
||||
retcode = SQLExecDirect(hstmtDelete, (SQLTCHAR FAR *) pSqlStmt.c_str(), SQL_NTS);
|
||||
retcode = SQLExecDirect(hstmtDelete, WXSQLCAST(pSqlStmt), SQL_NTS);
|
||||
|
||||
if (retcode == SQL_SUCCESS ||
|
||||
retcode == SQL_NO_DATA_FOUND ||
|
||||
@@ -637,7 +644,7 @@ bool wxDbTable::execUpdate(const wxString &pSqlStmt)
|
||||
RETCODE retcode;
|
||||
|
||||
// Execute the UPDATE statement
|
||||
retcode = SQLExecDirect(hstmtUpdate, (SQLTCHAR FAR *) pSqlStmt.c_str(), SQL_NTS);
|
||||
retcode = SQLExecDirect(hstmtUpdate, WXSQLCAST(pSqlStmt), SQL_NTS);
|
||||
|
||||
if (retcode == SQL_SUCCESS ||
|
||||
retcode == SQL_NO_DATA_FOUND ||
|
||||
@@ -709,7 +716,7 @@ bool wxDbTable::query(int queryType, bool forUpdate, bool distinct, const wxStri
|
||||
|
||||
// Execute the SQL SELECT statement
|
||||
int retcode;
|
||||
retcode = SQLExecDirect(hstmt, (SQLTCHAR FAR *) (queryType == DB_SELECT_STATEMENT ? pSqlStmt.c_str() : sqlStmt.c_str()), SQL_NTS);
|
||||
retcode = SQLExecDirect(hstmt, (queryType == DB_SELECT_STATEMENT ? WXSQLCAST(pSqlStmt) : WXSQLCAST(sqlStmt)), SQL_NTS);
|
||||
if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO)
|
||||
return(pDb->DispAllErrors(henv, hdbc, hstmt));
|
||||
|
||||
@@ -848,7 +855,7 @@ bool wxDbTable::Open(bool checkPrivileges, bool checkTableExists)
|
||||
// Prepare the insert statement for execution
|
||||
if (insertableCount)
|
||||
{
|
||||
if (SQLPrepare(hstmtInsert, (SQLTCHAR FAR *) sqlStmt.c_str(), SQL_NTS) != SQL_SUCCESS)
|
||||
if (SQLPrepare(hstmtInsert, WXSQLCAST(sqlStmt), SQL_NTS) != SQL_SUCCESS)
|
||||
return(pDb->DispAllErrors(henv, hdbc, hstmtInsert));
|
||||
}
|
||||
else
|
||||
@@ -1563,7 +1570,7 @@ bool wxDbTable::CreateTable(bool attemptDrop)
|
||||
#endif
|
||||
|
||||
// Execute the CREATE TABLE statement
|
||||
RETCODE retcode = SQLExecDirect(hstmt, (SQLTCHAR FAR *) sqlStmt.c_str(), SQL_NTS);
|
||||
RETCODE retcode = SQLExecDirect(hstmt, WXSQLCAST(sqlStmt), SQL_NTS);
|
||||
if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO)
|
||||
{
|
||||
pDb->DispAllErrors(henv, hdbc, hstmt);
|
||||
@@ -1603,7 +1610,7 @@ bool wxDbTable::DropTable()
|
||||
cout << endl << sqlStmt.c_str() << endl;
|
||||
#endif
|
||||
|
||||
RETCODE retcode = SQLExecDirect(hstmt, (SQLTCHAR FAR *) sqlStmt.c_str(), SQL_NTS);
|
||||
RETCODE retcode = SQLExecDirect(hstmt, WXSQLCAST(sqlStmt), SQL_NTS);
|
||||
if (retcode != SQL_SUCCESS)
|
||||
{
|
||||
// Check for "Base table not found" error and ignore
|
||||
@@ -1772,7 +1779,7 @@ bool wxDbTable::CreateIndex(const wxString &indexName, bool unique, UWORD numInd
|
||||
#endif
|
||||
|
||||
// Execute the CREATE INDEX statement
|
||||
RETCODE retcode = SQLExecDirect(hstmt, (SQLTCHAR FAR *) sqlStmt.c_str(), SQL_NTS);
|
||||
RETCODE retcode = SQLExecDirect(hstmt, WXSQLCAST(sqlStmt), SQL_NTS);
|
||||
if (retcode != SQL_SUCCESS)
|
||||
{
|
||||
pDb->DispAllErrors(henv, hdbc, hstmt);
|
||||
@@ -1823,7 +1830,7 @@ bool wxDbTable::DropIndex(const wxString &indexName)
|
||||
#ifdef DBDEBUG_CONSOLE
|
||||
cout << endl << sqlStmt.c_str() << endl;
|
||||
#endif
|
||||
RETCODE retcode = SQLExecDirect(hstmt, (SQLTCHAR FAR *) sqlStmt.c_str(), SQL_NTS);
|
||||
RETCODE retcode = SQLExecDirect(hstmt, WXSQLCAST(sqlStmt), SQL_NTS);
|
||||
if (retcode != SQL_SUCCESS)
|
||||
{
|
||||
// Check for "Index not found" error and ignore
|
||||
@@ -2470,7 +2477,7 @@ ULONG wxDbTable::Count(const wxString &args)
|
||||
}
|
||||
|
||||
// Execute the SQL statement
|
||||
if (SQLExecDirect(*hstmtCount, (SQLTCHAR FAR *) sqlStmt.c_str(), SQL_NTS) != SQL_SUCCESS)
|
||||
if (SQLExecDirect(*hstmtCount, WXSQLCAST(sqlStmt), SQL_NTS) != SQL_SUCCESS)
|
||||
{
|
||||
pDb->DispAllErrors(henv, hdbc, *hstmtCount);
|
||||
return(0);
|
||||
|
||||
Reference in New Issue
Block a user