+ return true;
+}
+
+bool wxDb::Open(const wxString& inConnectStr, bool failOnDataTypeUnsupported)
+{
+ wxASSERT(inConnectStr.length());
+ return Open(inConnectStr, NULL, failOnDataTypeUnsupported);
+}
+
+bool wxDb::Open(const wxString& inConnectStr, SQLHWND parentWnd, bool failOnDataTypeUnsupported)
+{
+ dsn = wxEmptyString;
+ uid = wxEmptyString;
+ authStr = wxEmptyString;
+
+ RETCODE retcode;
+
+ if (!FwdOnlyCursors())
+ {
+ // Specify that the ODBC cursor library be used, if needed. This must be
+ // specified before the connection is made.
+ retcode = SQLSetConnectOption(hdbc, SQL_ODBC_CURSORS, SQL_CUR_USE_IF_NEEDED);
+
+#ifdef DBDEBUG_CONSOLE
+ if (retcode == SQL_SUCCESS)
+ cout << wxT("SQLSetConnectOption(CURSOR_LIB) successful") << endl;
+ else
+ cout << wxT("SQLSetConnectOption(CURSOR_LIB) failed") << endl;
+#else
+ wxUnusedVar(retcode);
+#endif
+ }
+
+ // Connect to the data source
+ SQLTCHAR outConnectBuffer[SQL_MAX_CONNECTSTR_LEN+1]; // MS recommends at least 1k buffer
+ short outConnectBufferLen;
+
+ inConnectionStr = inConnectStr;
+
+ retcode = SQLDriverConnect(hdbc, parentWnd, (SQLTCHAR FAR *)inConnectionStr.c_str(),
+ (SWORD)inConnectionStr.length(), (SQLTCHAR FAR *)outConnectBuffer,
+ WXSIZEOF(outConnectBuffer), &outConnectBufferLen, SQL_DRIVER_COMPLETE );
+
+ if ((retcode != SQL_SUCCESS) &&
+ (retcode != SQL_SUCCESS_WITH_INFO))
+ return(DispAllErrors(henv, hdbc));
+
+ outConnectBuffer[outConnectBufferLen] = 0;
+ outConnectionStr = outConnectBuffer;
+ dbOpenedWithConnectionString = true;
+
+ return open(failOnDataTypeUnsupported);
+}
+
+/********** wxDb::Open() **********/
+bool wxDb::Open(const wxString &Dsn, const wxString &Uid, const wxString &AuthStr, bool failOnDataTypeUnsupported)
+{
+ wxASSERT(!Dsn.empty());
+ dsn = Dsn;
+ uid = Uid;
+ authStr = AuthStr;
+
+ inConnectionStr = wxEmptyString;
+ outConnectionStr = wxEmptyString;
+
+ RETCODE retcode;
+
+ if (!FwdOnlyCursors())
+ {
+ // Specify that the ODBC cursor library be used, if needed. This must be
+ // specified before the connection is made.
+ retcode = SQLSetConnectOption(hdbc, SQL_ODBC_CURSORS, SQL_CUR_USE_IF_NEEDED);
+
+#ifdef DBDEBUG_CONSOLE
+ if (retcode == SQL_SUCCESS)
+ cout << wxT("SQLSetConnectOption(CURSOR_LIB) successful") << endl;
+ else
+ cout << wxT("SQLSetConnectOption(CURSOR_LIB) failed") << endl;
+#else
+ wxUnusedVar( retcode );
+#endif
+ }
+
+ // Connect to the data source
+ retcode = SQLConnect(hdbc, (SQLTCHAR FAR *) dsn.c_str(), SQL_NTS,
+ (SQLTCHAR FAR *) uid.c_str(), SQL_NTS,
+ (SQLTCHAR FAR *) authStr.c_str(), SQL_NTS);
+
+ if ((retcode != SQL_SUCCESS) &&
+ (retcode != SQL_SUCCESS_WITH_INFO))
+ return(DispAllErrors(henv, hdbc));
+
+ return open(failOnDataTypeUnsupported);