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))
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))
while (SQLError(aHenv, aHdbc, aHstmt, (SQLTCHAR FAR *) sqlState, &nativeError, (SQLTCHAR FAR *) errorMsg, SQL_MAX_MESSAGE_LENGTH - 1, &cbErrorMsg) == SQL_SUCCESS)
{
- odbcErrMsg.Printf(wxT("SQL State = %s\nNative Error Code = %li\nError Message = %s\n"), sqlState, nativeError, errorMsg);
+ odbcErrMsg.Printf(wxT("SQL State = %s\nNative Error Code = %li\nError Message = %s\n"),
+ sqlState, (long)nativeError, errorMsg);
logError(odbcErrMsg, sqlState);
if (!silent)
{
{
wxString odbcErrMsg;
- odbcErrMsg.Printf(wxT("SQL State = %s\nNative Error Code = %li\nError Message = %s\n"), sqlState, nativeError, errorMsg);
+ odbcErrMsg.Printf(wxT("SQL State = %s\nNative Error Code = %li\nError Message = %s\n"),
+ sqlState, (long)nativeError, errorMsg);
logError(odbcErrMsg, sqlState);
if (silent)
} // 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)