+}
+
+bool wxDb::Open(const wxString& inConnectStr, bool failOnDataTypeUnsupported)
+{
+ wxASSERT(inConnectStr.Length());
+ dsn = wxT("");
+ uid = wxT("");
+ authStr = wxT("");
+
+ 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, NULL, (SQLTCHAR FAR *)inConnectionStr.c_str(),
+ inConnectionStr.Length(), (SQLTCHAR FAR *)outConnectBuffer,
+ sizeof(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.Length());
+ dsn = Dsn;
+ uid = Uid;
+ authStr = AuthStr;
+
+ inConnectionStr = wxT("");
+ outConnectionStr = wxT("");
+
+ 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);