+ // Float
+ if (!getDataTypeInfo(SQL_DOUBLE,typeInfFloat))
+ if (!getDataTypeInfo(SQL_REAL,typeInfFloat))
+ if (!getDataTypeInfo(SQL_FLOAT,typeInfFloat))
+ if (!getDataTypeInfo(SQL_DECIMAL,typeInfFloat))
+ if (!getDataTypeInfo(SQL_NUMERIC,typeInfFloat))
+ return(false);
+ else
+ typeInfFloat.FsqlType = SQL_NUMERIC;
+ else
+ typeInfFloat.FsqlType = SQL_DECIMAL;
+ else
+ typeInfFloat.FsqlType = SQL_FLOAT;
+ else
+ typeInfFloat.FsqlType = SQL_REAL;
+ else
+ typeInfFloat.FsqlType = SQL_DOUBLE;
+
+ // Integer
+ if (!getDataTypeInfo(SQL_INTEGER, typeInfInteger))
+ {
+ // If SQL_INTEGER is not supported, use the floating point
+ // data type to store integers as well as floats
+ if (!getDataTypeInfo(typeInfFloat.FsqlType, typeInfInteger))
+ return(false);
+ else
+ typeInfInteger.FsqlType = typeInfFloat.FsqlType;
+ }
+ else
+ typeInfInteger.FsqlType = SQL_INTEGER;
+
+ // Date/Time
+ if (Dbms() != dbmsDBASE)
+ {
+ if (!getDataTypeInfo(SQL_TIMESTAMP,typeInfDate))
+ return(false);
+ else
+ typeInfDate.FsqlType = SQL_TIMESTAMP;
+ }
+ else
+ {
+ if (!getDataTypeInfo(SQL_DATE,typeInfDate))
+ return(false);
+ else
+ typeInfDate.FsqlType = SQL_DATE;
+ }
+
+ if (!getDataTypeInfo(SQL_LONGVARBINARY, typeInfBlob))
+ {
+ if (!getDataTypeInfo(SQL_VARBINARY,typeInfBlob))
+ return(false);
+ else
+ typeInfBlob.FsqlType = SQL_VARBINARY;
+ }
+ else
+ typeInfBlob.FsqlType = SQL_LONGVARBINARY;
+
+//typeInfBlob.TypeName = "BLOB";
+
+#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 << wxT("BLOB DATA TYPE: ") << typeInfBlob.TypeName << endl;
+ cout << endl;
+#endif
+
+ // Completed Successfully
+ return(true);
+
+} // wxDb::Open()
+
+
+bool wxDb::Open(wxDbConnectInf *dbConnectInf)
+{
+ return Open(dbConnectInf->GetDsn(), dbConnectInf->GetUserID(),
+ dbConnectInf->GetPassword());
+} // wxDb::Open()
+
+
+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) wxEmptyString);
+ SQLSetConnectOption(hdbc, 1042, (UDWORD) wxEmptyString);
+*/
+
+ // 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;