+ // 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))
+ {
+ if (failOnDataTypeUnsupported)
+ return(FALSE);
+ }
+ else
+ typeInfInteger.FsqlType = typeInfFloat.FsqlType;
+ }
+ else
+ typeInfInteger.FsqlType = SQL_INTEGER;
+
+ // Date/Time
+ if (!getDataTypeInfo(SQL_TIMESTAMP,typeInfDate))
+ {
+ if (!getDataTypeInfo(SQL_DATE,typeInfDate))
+ {
+#ifdef SQL_DATETIME
+ if (getDataTypeInfo(SQL_DATETIME,typeInfDate))
+ {
+ typeInfDate.FsqlType = SQL_TIME;
+ }
+ else
+#endif // SQL_DATETIME defined
+ {
+ if (failOnDataTypeUnsupported)
+ return(FALSE);
+ }
+ }
+ else
+ typeInfDate.FsqlType = SQL_DATE;
+ }
+ else
+ typeInfDate.FsqlType = SQL_TIMESTAMP;
+
+
+ if (!getDataTypeInfo(SQL_LONGVARBINARY, typeInfBlob))
+ {
+ if (!getDataTypeInfo(SQL_VARBINARY,typeInfBlob))
+ {
+ if (failOnDataTypeUnsupported)
+ 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, (SQLTCHAR FAR *) dsn.c_str(), SQL_NTS,
+ (SQLTCHAR FAR *) uid.c_str(), SQL_NTS,
+ (SQLTCHAR 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;
+
+ // 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;