+ // VARCHAR = Variable length character string
+ if (!getDataTypeInfo(SQL_VARCHAR, typeInfVarchar))
+ if (!getDataTypeInfo(SQL_CHAR, typeInfVarchar))
+ return(FALSE);
+ else
+ typeInfVarchar.FsqlType = SQL_CHAR;
+ else
+ typeInfVarchar.FsqlType = SQL_VARCHAR;
+
+ // 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))
+ {
+ if (failOnDataTypeUnsupported)
+ 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))
+ {
+ 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, (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);