+bool wxDb::Open(wxDb *copyDb)
+{
+ dsn = copyDb->GetDatasourceName();
+ uid = copyDb->GetUsername();
+ authStr = copyDb->GetPassword();
+
+ 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;
+#endif
+ }
+
+ // Connect to the data source
+ retcode = SQLConnect(hdbc, (UCHAR FAR *) dsn.c_str(), SQL_NTS,
+ (UCHAR FAR *) uid.c_str(), SQL_NTS,
+ (UCHAR FAR *) authStr.c_str(), SQL_NTS);
+
+ if (retcode == SQL_ERROR)
+ return(DispAllErrors(henv, hdbc));
+
+/*
+ If using Intersolv branded ODBC drivers, this is the place where you would substitute
+ your branded driver license information
+
+ SQLSetConnectOption(hdbc, 1041, (UDWORD) wxT(""));
+ SQLSetConnectOption(hdbc, 1042, (UDWORD) wxT(""));
+*/
+
+ // Mark database as open
+ dbIsOpen = TRUE;
+
+ // Allocate a statement handle for the database connection
+ if (SQLAllocStmt(hdbc, &hstmt) != SQL_SUCCESS)
+ return(DispAllErrors(henv, hdbc));
+
+ // Set Connection Options
+ if (!setConnectionOptions())
+ return(FALSE);
+
+ // Instead of Querying the data source for info about itself, it can just be copied
+ // from the wxDb instance that was passed in (copyDb).
+ wxStrcpy(dbInf.serverName,copyDb->dbInf.serverName);
+ wxStrcpy(dbInf.databaseName,copyDb->dbInf.databaseName);
+ wxStrcpy(dbInf.dbmsName,copyDb->dbInf.dbmsName);
+ wxStrcpy(dbInf.dbmsVer,copyDb->dbInf.dbmsVer);
+ dbInf.maxConnections = copyDb->dbInf.maxConnections;
+ dbInf.maxStmts = copyDb->dbInf.maxStmts;
+ wxStrcpy(dbInf.driverName,copyDb->dbInf.driverName);
+ wxStrcpy(dbInf.odbcVer,copyDb->dbInf.odbcVer);
+ wxStrcpy(dbInf.drvMgrOdbcVer,copyDb->dbInf.drvMgrOdbcVer);
+ wxStrcpy(dbInf.driverVer,copyDb->dbInf.driverVer);
+ dbInf.apiConfLvl = copyDb->dbInf.apiConfLvl;
+ dbInf.cliConfLvl = copyDb->dbInf.cliConfLvl;
+ dbInf.sqlConfLvl = copyDb->dbInf.sqlConfLvl;
+ wxStrcpy(dbInf.outerJoins,copyDb->dbInf.outerJoins);
+ wxStrcpy(dbInf.procedureSupport,copyDb->dbInf.procedureSupport);
+ wxStrcpy(dbInf.accessibleTables,copyDb->dbInf.accessibleTables);
+ dbInf.cursorCommitBehavior = copyDb->dbInf.cursorCommitBehavior;
+ dbInf.cursorRollbackBehavior = copyDb->dbInf.cursorRollbackBehavior;
+ dbInf.supportNotNullClause = copyDb->dbInf.supportNotNullClause;
+ wxStrcpy(dbInf.supportIEF,copyDb->dbInf.supportIEF);
+ dbInf.txnIsolation = copyDb->dbInf.txnIsolation;
+ dbInf.txnIsolationOptions = copyDb->dbInf.txnIsolationOptions;
+ dbInf.fetchDirections = copyDb->dbInf.fetchDirections;
+ dbInf.lockTypes = copyDb->dbInf.lockTypes;
+ dbInf.posOperations = copyDb->dbInf.posOperations;
+ dbInf.posStmts = copyDb->dbInf.posStmts;
+ dbInf.scrollConcurrency = copyDb->dbInf.scrollConcurrency;
+ dbInf.scrollOptions = copyDb->dbInf.scrollOptions;
+ dbInf.staticSensitivity = copyDb->dbInf.staticSensitivity;
+ dbInf.txnCapable = copyDb->dbInf.txnCapable;
+ dbInf.loginTimeout = copyDb->dbInf.loginTimeout;
+
+ // VARCHAR = Variable length character string
+ typeInfVarchar.FsqlType = copyDb->typeInfVarchar.FsqlType;
+ typeInfVarchar.TypeName = copyDb->typeInfVarchar.TypeName;
+ typeInfVarchar.Precision = copyDb->typeInfVarchar.Precision;
+ typeInfVarchar.CaseSensitive = copyDb->typeInfVarchar.CaseSensitive;
+ typeInfVarchar.MaximumScale = copyDb->typeInfVarchar.MaximumScale;
+
+ // Float
+ typeInfFloat.FsqlType = copyDb->typeInfFloat.FsqlType;
+ typeInfFloat.TypeName = copyDb->typeInfFloat.TypeName;
+ typeInfFloat.Precision = copyDb->typeInfFloat.Precision;
+ typeInfFloat.CaseSensitive = copyDb->typeInfFloat.CaseSensitive;
+ typeInfFloat.MaximumScale = copyDb->typeInfFloat.MaximumScale;
+
+ // Integer
+ typeInfInteger.FsqlType = copyDb->typeInfInteger.FsqlType;
+ typeInfInteger.TypeName = copyDb->typeInfInteger.TypeName;
+ typeInfInteger.Precision = copyDb->typeInfInteger.Precision;
+ typeInfInteger.CaseSensitive = copyDb->typeInfInteger.CaseSensitive;
+ typeInfInteger.MaximumScale = copyDb->typeInfInteger.MaximumScale;
+
+ // Date/Time
+ typeInfDate.FsqlType = copyDb->typeInfDate.FsqlType;
+ typeInfDate.TypeName = copyDb->typeInfDate.TypeName;
+ typeInfDate.Precision = copyDb->typeInfDate.Precision;
+ typeInfDate.CaseSensitive = copyDb->typeInfDate.CaseSensitive;
+ typeInfDate.MaximumScale = copyDb->typeInfDate.MaximumScale;
+
+#ifdef DBDEBUG_CONSOLE
+ cout << wxT("VARCHAR DATA TYPE: ") << typeInfVarchar.TypeName << endl;
+ cout << wxT("INTEGER DATA TYPE: ") << typeInfInteger.TypeName << endl;
+ cout << wxT("FLOAT DATA TYPE: ") << typeInfFloat.TypeName << endl;
+ cout << wxT("DATE DATA TYPE: ") << typeInfDate.TypeName << endl;
+ cout << endl;
+#endif
+
+ // Completed Successfully
+ return(TRUE);
+} // wxDb::Open() 2
+
+
+/********** wxDb::setConnectionOptions() **********/
+bool wxDb::setConnectionOptions(void)