X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d595fb29c93249b72930cad9a85a5c237a8ceff7..72366f68d1036084d1adc5971eeee4885f36fe5c:/src/common/db.cpp diff --git a/src/common/db.cpp b/src/common/db.cpp index b1640ae1dd..0e99d44d21 100644 --- a/src/common/db.cpp +++ b/src/common/db.cpp @@ -858,7 +858,7 @@ bool wxDb::Open(const wxString& inConnectStr, SQLHWND parentWnd, bool failOnData retcode = SQLDriverConnect(hdbc, parentWnd, (SQLTCHAR FAR *)inConnectionStr.c_str(), (SWORD)inConnectionStr.length(), (SQLTCHAR FAR *)outConnectBuffer, - sizeof(outConnectBuffer), &outConnectBufferLen, SQL_DRIVER_COMPLETE ); + WXSIZEOF(outConnectBuffer), &outConnectBufferLen, SQL_DRIVER_COMPLETE ); if ((retcode != SQL_SUCCESS) && (retcode != SQL_SUCCESS_WITH_INFO)) @@ -920,7 +920,7 @@ bool wxDb::Open(wxDbConnectInf *dbConnectInf, bool failOnDataTypeUnsupported) // Use the connection string if one is present if (dbConnectInf->UseConnectionStr()) - return Open(GetConnectionInStr(), failOnDataTypeUnsupported); + return Open(dbConnectInf->GetConnectionStr(), failOnDataTypeUnsupported); else return Open(dbConnectInf->GetDsn(), dbConnectInf->GetUserID(), dbConnectInf->GetPassword(), failOnDataTypeUnsupported); @@ -963,7 +963,7 @@ bool wxDb::Open(wxDb *copyDb) retcode = SQLDriverConnect(hdbc, NULL, (SQLTCHAR FAR *)inConnectionStr.c_str(), (SWORD)inConnectionStr.length(), (SQLTCHAR FAR *)outConnectBuffer, - sizeof(outConnectBuffer), &outConnectBufferLen, SQL_DRIVER_COMPLETE); + WXSIZEOF(outConnectBuffer), &outConnectBufferLen, SQL_DRIVER_COMPLETE); if ((retcode != SQL_SUCCESS) && (retcode != SQL_SUCCESS_WITH_INFO)) @@ -4086,6 +4086,28 @@ bool wxDb::ModifyColumn(const wxString &tableName, const wxString &columnName, } // wxDb::ModifyColumn() +/********** wxDb::EscapeSqlChars() **********/ +wxString wxDb::EscapeSqlChars(const wxString& valueOrig) +{ + wxString value(valueOrig); + switch (Dbms()) + { + case dbmsACCESS: + // Access doesn't seem to care about backslashes, so only escape single quotes. + value.Replace(wxT("'"), wxT("''")); + break; + + default: + // All the others are supposed to be the same for now, add special + // handling for them if necessary + value.Replace(wxT("\\"), wxT("\\\\")); + value.Replace(wxT("'"), wxT("\\'")); + break; + } + + return value; +} // wxDb::EscapeSqlChars() + /********** wxDbGetConnection() **********/ wxDb WXDLLIMPEXP_ODBC *wxDbGetConnection(wxDbConnectInf *pDbConfig, bool FwdOnlyCursors)