Unicode support
Several error conditions when connecting to databases are corrected git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30270 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -83,6 +83,11 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
#define SQL_C_WXCHAR SQL_C_WCHAR
|
||||
#else
|
||||
#define SQL_C_WXCHAR SQL_C_CHAR
|
||||
#endif
|
||||
|
||||
typedef float SFLOAT;
|
||||
typedef double SDOUBLE;
|
||||
@@ -365,7 +370,7 @@ public:
|
||||
~wxDbColFor(){}
|
||||
|
||||
void Initialize();
|
||||
int Format(int Nation, int dbDataType, SWORD sqlDataType, short columnSize, short decimalDigits);
|
||||
int Format(int Nation, int dbDataType, SWORD sqlDataType, short columnLength, short decimalDigits);
|
||||
};
|
||||
|
||||
|
||||
@@ -378,8 +383,8 @@ public:
|
||||
wxChar colName[DB_MAX_COLUMN_NAME_LEN+1];
|
||||
SWORD sqlDataType;
|
||||
wxChar typeName[128+1];
|
||||
SWORD columnSize;
|
||||
SWORD bufferLength;
|
||||
SWORD columnLength;
|
||||
SWORD bufferSize;
|
||||
short decimalDigits;
|
||||
short numPrecRadix;
|
||||
short nullable;
|
||||
@@ -750,8 +755,8 @@ int WXDLLEXPORT wxDbCreateDataSource(const wxString &driverName, const wxString
|
||||
// the first time using SQL_FETCH_FIRST. Continue to call it
|
||||
// using SQL_FETCH_NEXT until you've exhausted the list.
|
||||
bool WXDLLIMPEXP_ODBC
|
||||
wxDbGetDataSource(HENV henv, wxChar *Dsn, SWORD DsnMax, wxChar *DsDesc,
|
||||
SWORD DsDescMax, UWORD direction = SQL_FETCH_NEXT);
|
||||
wxDbGetDataSource(HENV henv, wxChar *Dsn, SWORD DsnMaxLength, wxChar *DsDesc,
|
||||
SWORD DsDescMaxLength, UWORD direction = SQL_FETCH_NEXT);
|
||||
|
||||
|
||||
// Change this to 0 to remove use of all deprecated functions
|
||||
@@ -791,7 +796,7 @@ int WXDLLIMPEXP_ODBC NumberDbConnectionsInUse(void);
|
||||
bool SqlLog(sqlLog state, const wxChar *filename = SQL_LOG_FILENAME);
|
||||
|
||||
bool WXDLLIMPEXP_ODBC
|
||||
GetDataSource(HENV henv, char *Dsn, SWORD DsnMax, char *DsDesc, SWORD DsDescMax,
|
||||
GetDataSource(HENV henv, char *Dsn, SWORD DsnMaxLength, char *DsDesc, SWORD DsDescMaxLength,
|
||||
UWORD direction = SQL_FETCH_NEXT);
|
||||
|
||||
#endif // Deprecated structures/classes/functions
|
||||
|
@@ -261,7 +261,7 @@ void wxDbColFor::Initialize()
|
||||
|
||||
/********** wxDbColFor::Format() **********/
|
||||
int wxDbColFor::Format(int Nation, int dbDataType, SWORD sqlDataType,
|
||||
short columnSize, short decimalDigits)
|
||||
short columnLength, short decimalDigits)
|
||||
{
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// -- 19991224 : mj10777 : Create
|
||||
@@ -314,7 +314,7 @@ int wxDbColFor::Format(int Nation, int dbDataType, SWORD sqlDataType,
|
||||
if (decimalDigits == 0)
|
||||
decimalDigits = 2;
|
||||
tempStr = wxT("%");
|
||||
tempStr.Printf(wxT("%s%d.%d"),tempStr.c_str(),columnSize,decimalDigits);
|
||||
tempStr.Printf(wxT("%s%d.%d"), tempStr.c_str(),columnLength, decimalDigits);
|
||||
s_Field.Printf(wxT("%sf"), tempStr.c_str());
|
||||
break;
|
||||
case DB_DATA_TYPE_DATE:
|
||||
@@ -350,7 +350,6 @@ int wxDbColFor::Format(int Nation, int dbDataType, SWORD sqlDataType,
|
||||
} // wxDbColFor::Format()
|
||||
|
||||
|
||||
|
||||
/********** wxDbColInf Constructor **********/
|
||||
wxDbColInf::wxDbColInf()
|
||||
{
|
||||
@@ -375,8 +374,8 @@ bool wxDbColInf::Initialize()
|
||||
colName[0] = 0;
|
||||
sqlDataType = 0;
|
||||
typeName[0] = 0;
|
||||
columnSize = 0;
|
||||
bufferLength = 0;
|
||||
columnLength = 0;
|
||||
bufferSize = 0;
|
||||
decimalDigits = 0;
|
||||
numPrecRadix = 0;
|
||||
nullable = 0;
|
||||
@@ -1008,11 +1007,14 @@ bool wxDb::setConnectionOptions(void)
|
||||
|
||||
// I need to get the DBMS name here, because some of the connection options
|
||||
// are database specific and need to call the Dbms() function.
|
||||
if (SQLGetInfo(hdbc, SQL_DBMS_NAME, (UCHAR*) dbInf.dbmsName, 40, &cb) != SQL_SUCCESS)
|
||||
RETCODE retcode;
|
||||
|
||||
retcode = SQLGetInfo(hdbc, SQL_DBMS_NAME, (UCHAR *) dbInf.dbmsName, sizeof(dbInf.dbmsName), &cb);
|
||||
if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO)
|
||||
return(DispAllErrors(henv, hdbc));
|
||||
|
||||
SQLSetConnectOption(hdbc, SQL_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF);
|
||||
SQLSetConnectOption(hdbc, SQL_OPT_TRACE, SQL_OPT_TRACE_OFF);
|
||||
retcode = SQLSetConnectOption(hdbc, SQL_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF);
|
||||
retcode = SQLSetConnectOption(hdbc, SQL_OPT_TRACE, SQL_OPT_TRACE_OFF);
|
||||
// SQLSetConnectOption(hdbc, SQL_TXN_ISOLATION, SQL_TXN_READ_COMMITTED); // No dirty reads
|
||||
|
||||
// By default, MS Sql Server closes cursors on commit and rollback. The following
|
||||
@@ -1024,7 +1026,7 @@ bool wxDb::setConnectionOptions(void)
|
||||
{
|
||||
const long SQL_PRESERVE_CURSORS = 1204L;
|
||||
const long SQL_PC_ON = 1L;
|
||||
SQLSetConnectOption(hdbc, SQL_PRESERVE_CURSORS, SQL_PC_ON);
|
||||
retcode = SQLSetConnectOption(hdbc, SQL_PRESERVE_CURSORS, SQL_PC_ON);
|
||||
}
|
||||
|
||||
// Display the connection options to verify them
|
||||
@@ -1032,11 +1034,13 @@ bool wxDb::setConnectionOptions(void)
|
||||
long l;
|
||||
cout << wxT("****** CONNECTION OPTIONS ******") << endl;
|
||||
|
||||
if (SQLGetConnectOption(hdbc, SQL_AUTOCOMMIT, &l) != SQL_SUCCESS)
|
||||
retcode = SQLGetConnectOption(hdbc, SQL_AUTOCOMMIT, &l);
|
||||
if (retcode != SQL_SUCCESS)
|
||||
return(DispAllErrors(henv, hdbc));
|
||||
cout << wxT("AUTOCOMMIT: ") << (l == SQL_AUTOCOMMIT_OFF ? "OFF" : "ON") << endl;
|
||||
|
||||
if (SQLGetConnectOption(hdbc, SQL_ODBC_CURSORS, &l) != SQL_SUCCESS)
|
||||
retcode = SQLGetConnectOption(hdbc, SQL_ODBC_CURSORS, &l);
|
||||
if (retcode != SQL_SUCCESS)
|
||||
return(DispAllErrors(henv, hdbc));
|
||||
cout << wxT("ODBC CURSORS: ");
|
||||
switch(l)
|
||||
@@ -1053,7 +1057,8 @@ bool wxDb::setConnectionOptions(void)
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
if (SQLGetConnectOption(hdbc, SQL_OPT_TRACE, &l) != SQL_SUCCESS)
|
||||
retcode = SQLGetConnectOption(hdbc, SQL_OPT_TRACE, &l)
|
||||
if (retcode != SQL_SUCCESS)
|
||||
return(DispAllErrors(henv, hdbc));
|
||||
cout << wxT("TRACING: ") << (l == SQL_OPT_TRACE_OFF ? wxT("OFF") : wxT("ON")) << endl;
|
||||
|
||||
@@ -1072,7 +1077,7 @@ bool wxDb::getDbInfo(bool failOnDataTypeUnsupported)
|
||||
SWORD cb;
|
||||
RETCODE retcode;
|
||||
|
||||
retcode = SQLGetInfo(hdbc, SQL_SERVER_NAME, (UCHAR*) dbInf.serverName, 80, &cb);
|
||||
retcode = SQLGetInfo(hdbc, SQL_SERVER_NAME, (UCHAR*) dbInf.serverName, sizeof(dbInf.serverName), &cb);
|
||||
if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
|
||||
{
|
||||
DispAllErrors(henv, hdbc);
|
||||
@@ -1080,7 +1085,7 @@ bool wxDb::getDbInfo(bool failOnDataTypeUnsupported)
|
||||
return false;
|
||||
}
|
||||
|
||||
retcode = SQLGetInfo(hdbc, SQL_DATABASE_NAME, (UCHAR*) dbInf.databaseName, 128, &cb);
|
||||
retcode = SQLGetInfo(hdbc, SQL_DATABASE_NAME, (UCHAR*) dbInf.databaseName, sizeof(dbInf.databaseName), &cb);
|
||||
if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
|
||||
{
|
||||
DispAllErrors(henv, hdbc);
|
||||
@@ -1088,7 +1093,7 @@ bool wxDb::getDbInfo(bool failOnDataTypeUnsupported)
|
||||
return false;
|
||||
}
|
||||
|
||||
retcode = SQLGetInfo(hdbc, SQL_DBMS_NAME, (UCHAR*) dbInf.dbmsName, 40, &cb);
|
||||
retcode = SQLGetInfo(hdbc, SQL_DBMS_NAME, (UCHAR*) dbInf.dbmsName, sizeof(dbInf.dbmsName), &cb);
|
||||
if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
|
||||
{
|
||||
DispAllErrors(henv, hdbc);
|
||||
@@ -1099,7 +1104,7 @@ bool wxDb::getDbInfo(bool failOnDataTypeUnsupported)
|
||||
// 16-Mar-1999
|
||||
// After upgrading to MSVC6, the original 20 char buffer below was insufficient,
|
||||
// causing database connectivity to fail in some cases.
|
||||
retcode = SQLGetInfo(hdbc, SQL_DBMS_VER, (UCHAR*) dbInf.dbmsVer, 64, &cb);
|
||||
retcode = SQLGetInfo(hdbc, SQL_DBMS_VER, (UCHAR*) dbInf.dbmsVer, sizeof(dbInf.dbmsVer), &cb);
|
||||
if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
|
||||
{
|
||||
DispAllErrors(henv, hdbc);
|
||||
@@ -1123,7 +1128,7 @@ bool wxDb::getDbInfo(bool failOnDataTypeUnsupported)
|
||||
return false;
|
||||
}
|
||||
|
||||
retcode = SQLGetInfo(hdbc, SQL_DRIVER_NAME, (UCHAR*) dbInf.driverName, 40, &cb);
|
||||
retcode = SQLGetInfo(hdbc, SQL_DRIVER_NAME, (UCHAR*) dbInf.driverName, sizeof(dbInf.driverName), &cb);
|
||||
if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
|
||||
{
|
||||
DispAllErrors(henv, hdbc);
|
||||
@@ -1131,7 +1136,7 @@ bool wxDb::getDbInfo(bool failOnDataTypeUnsupported)
|
||||
return false;
|
||||
}
|
||||
|
||||
retcode = SQLGetInfo(hdbc, SQL_DRIVER_ODBC_VER, (UCHAR*) dbInf.odbcVer, 60, &cb);
|
||||
retcode = SQLGetInfo(hdbc, SQL_DRIVER_ODBC_VER, (UCHAR*) dbInf.odbcVer, sizeof(dbInf.odbcVer), &cb);
|
||||
if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
|
||||
{
|
||||
DispAllErrors(henv, hdbc);
|
||||
@@ -1139,7 +1144,7 @@ bool wxDb::getDbInfo(bool failOnDataTypeUnsupported)
|
||||
return false;
|
||||
}
|
||||
|
||||
retcode = SQLGetInfo(hdbc, SQL_ODBC_VER, (UCHAR*) dbInf.drvMgrOdbcVer, 60, &cb);
|
||||
retcode = SQLGetInfo(hdbc, SQL_ODBC_VER, (UCHAR*) dbInf.drvMgrOdbcVer, sizeof(dbInf.drvMgrOdbcVer), &cb);
|
||||
if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO)
|
||||
{
|
||||
DispAllErrors(henv, hdbc);
|
||||
@@ -1147,7 +1152,7 @@ bool wxDb::getDbInfo(bool failOnDataTypeUnsupported)
|
||||
return false;
|
||||
}
|
||||
|
||||
retcode = SQLGetInfo(hdbc, SQL_DRIVER_VER, (UCHAR*) dbInf.driverVer, 60, &cb);
|
||||
retcode = SQLGetInfo(hdbc, SQL_DRIVER_VER, (UCHAR*) dbInf.driverVer, sizeof(dbInf.driverVer), &cb);
|
||||
if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
|
||||
{
|
||||
DispAllErrors(henv, hdbc);
|
||||
@@ -1181,7 +1186,7 @@ bool wxDb::getDbInfo(bool failOnDataTypeUnsupported)
|
||||
return false;
|
||||
}
|
||||
|
||||
retcode = SQLGetInfo(hdbc, SQL_OUTER_JOINS, (UCHAR*) dbInf.outerJoins, 2, &cb);
|
||||
retcode = SQLGetInfo(hdbc, SQL_OUTER_JOINS, (UCHAR*) dbInf.outerJoins, sizeof(dbInf.outerJoins), &cb);
|
||||
if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
|
||||
{
|
||||
DispAllErrors(henv, hdbc);
|
||||
@@ -1189,7 +1194,7 @@ bool wxDb::getDbInfo(bool failOnDataTypeUnsupported)
|
||||
return false;
|
||||
}
|
||||
|
||||
retcode = SQLGetInfo(hdbc, SQL_PROCEDURES, (UCHAR*) dbInf.procedureSupport, 2, &cb);
|
||||
retcode = SQLGetInfo(hdbc, SQL_PROCEDURES, (UCHAR*) dbInf.procedureSupport, sizeof(dbInf.procedureSupport), &cb);
|
||||
if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
|
||||
{
|
||||
DispAllErrors(henv, hdbc);
|
||||
@@ -1197,7 +1202,7 @@ bool wxDb::getDbInfo(bool failOnDataTypeUnsupported)
|
||||
return false;
|
||||
}
|
||||
|
||||
retcode = SQLGetInfo(hdbc, SQL_ACCESSIBLE_TABLES, (UCHAR*) dbInf.accessibleTables, 2, &cb);
|
||||
retcode = SQLGetInfo(hdbc, SQL_ACCESSIBLE_TABLES, (UCHAR*) dbInf.accessibleTables, sizeof(dbInf.accessibleTables), &cb);
|
||||
if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
|
||||
{
|
||||
DispAllErrors(henv, hdbc);
|
||||
@@ -1229,7 +1234,7 @@ bool wxDb::getDbInfo(bool failOnDataTypeUnsupported)
|
||||
return false;
|
||||
}
|
||||
|
||||
retcode = SQLGetInfo(hdbc, SQL_ODBC_SQL_OPT_IEF, (UCHAR*) dbInf.supportIEF, 2, &cb);
|
||||
retcode = SQLGetInfo(hdbc, SQL_ODBC_SQL_OPT_IEF, (UCHAR*) dbInf.supportIEF, sizeof(dbInf.supportIEF), &cb);
|
||||
if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
|
||||
{
|
||||
DispAllErrors(henv, hdbc);
|
||||
@@ -1558,7 +1563,7 @@ bool wxDb::getDataTypeInfo(SWORD fSqlType, wxDbSqlTypeInfo &structSQLTypeInfo)
|
||||
wxChar typeName[DB_TYPE_NAME_LEN+1];
|
||||
|
||||
// Obtain columns from the record
|
||||
if (SQLGetData(hstmt, 1, SQL_C_CHAR, (UCHAR*) typeName, DB_TYPE_NAME_LEN, &cbRet) != SQL_SUCCESS)
|
||||
if (SQLGetData(hstmt, 1, SQL_C_WXCHAR, typeName, sizeof(typeName), &cbRet) != SQL_SUCCESS)
|
||||
return(DispAllErrors(henv, hdbc, hstmt));
|
||||
|
||||
structSQLTypeInfo.TypeName = typeName;
|
||||
@@ -2178,7 +2183,12 @@ bool wxDb::GetData(UWORD colNo, SWORD cType, PTR pData, SDWORD maxLen, SDWORD FA
|
||||
wxASSERT(pData);
|
||||
wxASSERT(cbReturned);
|
||||
|
||||
if (SQLGetData(hstmt, colNo, cType, pData, maxLen, cbReturned) == SQL_SUCCESS)
|
||||
long bufferSize = maxLen;
|
||||
|
||||
if (cType == SQL_C_WXCHAR)
|
||||
bufferSize = maxLen * sizeof(wxChar);
|
||||
|
||||
if (SQLGetData(hstmt, colNo, cType, pData, bufferSize, cbReturned) == SQL_SUCCESS)
|
||||
return true;
|
||||
else
|
||||
{
|
||||
@@ -2232,7 +2242,7 @@ int wxDb::GetKeyFields(const wxString &tableName, wxDbColInf* colInf, UWORD noCo
|
||||
retcode = SQLFetch(hstmt);
|
||||
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
|
||||
{
|
||||
GetData( 4, SQL_C_CHAR, szPkCol, DB_MAX_COLUMN_NAME_LEN+1, &cb);
|
||||
GetData( 4, SQL_C_WXCHAR, szPkCol, DB_MAX_COLUMN_NAME_LEN+1, &cb);
|
||||
GetData( 5, SQL_C_SSHORT, &iKeySeq, 0, &cb);
|
||||
//-------
|
||||
for (i=0;i<noCols;i++) // Find the Column name
|
||||
@@ -2264,11 +2274,11 @@ int wxDb::GetKeyFields(const wxString &tableName, wxDbColInf* colInf, UWORD noCo
|
||||
retcode = SQLFetch(hstmt);
|
||||
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
|
||||
{
|
||||
GetData( 3, SQL_C_CHAR, szPkTable, DB_MAX_TABLE_NAME_LEN+1, &cb);
|
||||
GetData( 4, SQL_C_CHAR, szPkCol, DB_MAX_COLUMN_NAME_LEN+1, &cb);
|
||||
GetData( 3, SQL_C_WXCHAR, szPkTable, DB_MAX_TABLE_NAME_LEN+1, &cb);
|
||||
GetData( 4, SQL_C_WXCHAR, szPkCol, DB_MAX_COLUMN_NAME_LEN+1, &cb);
|
||||
GetData( 5, SQL_C_SSHORT, &iKeySeq, 0, &cb);
|
||||
GetData( 7, SQL_C_CHAR, szFkTable, DB_MAX_TABLE_NAME_LEN+1, &cb);
|
||||
GetData( 8, SQL_C_CHAR, szFkCol, DB_MAX_COLUMN_NAME_LEN+1, &cb);
|
||||
GetData( 7, SQL_C_WXCHAR, szFkTable, DB_MAX_TABLE_NAME_LEN+1, &cb);
|
||||
GetData( 8, SQL_C_WXCHAR, szFkCol, DB_MAX_COLUMN_NAME_LEN+1, &cb);
|
||||
tempStr.Printf(wxT("%s[%s] "),tempStr.c_str(),szFkTable); // [ ] in case there is a blank in the Table name
|
||||
} // if
|
||||
} // while
|
||||
@@ -2306,9 +2316,9 @@ int wxDb::GetKeyFields(const wxString &tableName, wxDbColInf* colInf, UWORD noCo
|
||||
retcode = SQLFetch(hstmt);
|
||||
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
|
||||
{
|
||||
GetData( 3, SQL_C_CHAR, szPkTable, DB_MAX_TABLE_NAME_LEN+1, &cb);
|
||||
GetData( 3, SQL_C_WXCHAR, szPkTable, DB_MAX_TABLE_NAME_LEN+1, &cb);
|
||||
GetData( 5, SQL_C_SSHORT, &iKeySeq, 0, &cb);
|
||||
GetData( 8, SQL_C_CHAR, szFkCol, DB_MAX_COLUMN_NAME_LEN+1, &cb);
|
||||
GetData( 8, SQL_C_WXCHAR, szFkCol, DB_MAX_COLUMN_NAME_LEN+1, &cb);
|
||||
//-------
|
||||
for (i=0; i<noCols; i++) // Find the Column name
|
||||
{
|
||||
@@ -2440,30 +2450,30 @@ wxDbColInf *wxDb::GetColumns(wxChar *tableName[], const wxChar *userID)
|
||||
if (colNo < noCols) // Some extra error checking to prevent memory overwrites
|
||||
{
|
||||
// NOTE: Only the ODBC 1.x fields are retrieved
|
||||
GetData( 1, SQL_C_CHAR, (UCHAR*) colInf[colNo].catalog, 128+1, &cb);
|
||||
GetData( 2, SQL_C_CHAR, (UCHAR*) colInf[colNo].schema, 128+1, &cb);
|
||||
GetData( 3, SQL_C_CHAR, (UCHAR*) colInf[colNo].tableName, DB_MAX_TABLE_NAME_LEN+1, &cb);
|
||||
GetData( 4, SQL_C_CHAR, (UCHAR*) colInf[colNo].colName, DB_MAX_COLUMN_NAME_LEN+1, &cb);
|
||||
GetData( 1, SQL_C_WXCHAR, (UCHAR*) colInf[colNo].catalog, 128+1, &cb);
|
||||
GetData( 2, SQL_C_WXCHAR, (UCHAR*) colInf[colNo].schema, 128+1, &cb);
|
||||
GetData( 3, SQL_C_WXCHAR, (UCHAR*) colInf[colNo].tableName, DB_MAX_TABLE_NAME_LEN+1, &cb);
|
||||
GetData( 4, SQL_C_WXCHAR, (UCHAR*) colInf[colNo].colName, DB_MAX_COLUMN_NAME_LEN+1, &cb);
|
||||
GetData( 5, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].sqlDataType, 0, &cb);
|
||||
GetData( 6, SQL_C_CHAR, (UCHAR*) colInf[colNo].typeName, 128+1, &cb);
|
||||
GetData( 7, SQL_C_SLONG, (UCHAR*) &colInf[colNo].columnSize, 0, &cb);
|
||||
GetData( 8, SQL_C_SLONG, (UCHAR*) &colInf[colNo].bufferLength, 0, &cb);
|
||||
GetData( 6, SQL_C_WXCHAR, (UCHAR*) colInf[colNo].typeName, 128+1, &cb);
|
||||
GetData( 7, SQL_C_SLONG, (UCHAR*) &colInf[colNo].columnLength, 0, &cb);
|
||||
GetData( 8, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].bufferSize, 0, &cb);
|
||||
GetData( 9, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].decimalDigits,0, &cb);
|
||||
GetData(10, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].numPrecRadix, 0, &cb);
|
||||
GetData(11, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].nullable, 0, &cb);
|
||||
GetData(12, SQL_C_CHAR, (UCHAR*) colInf[colNo].remarks, 254+1, &cb);
|
||||
GetData(12, SQL_C_WXCHAR, (UCHAR*) colInf[colNo].remarks, 254+1, &cb);
|
||||
|
||||
// Determine the wxDb data type that is used to represent the native data type of this data source
|
||||
colInf[colNo].dbDataType = 0;
|
||||
if (!wxStricmp(typeInfVarchar.TypeName,colInf[colNo].typeName))
|
||||
{
|
||||
#ifdef _IODBC_
|
||||
// IODBC does not return a correct columnSize, so we set
|
||||
// columnSize = bufferLength if no column size was returned
|
||||
// IODBC returns the columnSize in bufferLength.. (bug)
|
||||
if (colInf[colNo].columnSize < 1)
|
||||
// IODBC does not return a correct columnLength, so we set
|
||||
// columnLength = bufferSize if no column length was returned
|
||||
// IODBC returns the columnLength in bufferSize. (bug)
|
||||
if (colInf[colNo].columnLength < 1)
|
||||
{
|
||||
colInf[colNo].columnSize = colInf[colNo].bufferLength;
|
||||
colInf[colNo].columnLength = colInf[colNo].bufferSize;
|
||||
}
|
||||
#endif
|
||||
colInf[colNo].dbDataType = DB_DATA_TYPE_VARCHAR;
|
||||
@@ -2597,19 +2607,19 @@ wxDbColInf *wxDb::GetColumns(const wxString &tableName, UWORD *numCols, const wx
|
||||
if (colNo < noCols) // Some extra error checking to prevent memory overwrites
|
||||
{
|
||||
// NOTE: Only the ODBC 1.x fields are retrieved
|
||||
GetData( 1, SQL_C_CHAR, (UCHAR*) colInf[colNo].catalog, 128+1, &cb);
|
||||
GetData( 2, SQL_C_CHAR, (UCHAR*) colInf[colNo].schema, 128+1, &cb);
|
||||
GetData( 3, SQL_C_CHAR, (UCHAR*) colInf[colNo].tableName, DB_MAX_TABLE_NAME_LEN+1, &cb);
|
||||
GetData( 4, SQL_C_CHAR, (UCHAR*) colInf[colNo].colName, DB_MAX_COLUMN_NAME_LEN+1, &cb);
|
||||
GetData( 1, SQL_C_WXCHAR, (UCHAR*) colInf[colNo].catalog, 128+1, &cb);
|
||||
GetData( 2, SQL_C_WXCHAR, (UCHAR*) colInf[colNo].schema, 128+1, &cb);
|
||||
GetData( 3, SQL_C_WXCHAR, (UCHAR*) colInf[colNo].tableName, DB_MAX_TABLE_NAME_LEN+1, &cb);
|
||||
GetData( 4, SQL_C_WXCHAR, (UCHAR*) colInf[colNo].colName, DB_MAX_COLUMN_NAME_LEN+1, &cb);
|
||||
GetData( 5, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].sqlDataType, 0, &cb);
|
||||
GetData( 6, SQL_C_CHAR, (UCHAR*) colInf[colNo].typeName, 128+1, &cb);
|
||||
GetData( 7, SQL_C_SLONG, (UCHAR*) &colInf[colNo].columnSize, 0, &cb);
|
||||
GetData( 6, SQL_C_WXCHAR, (UCHAR*) colInf[colNo].typeName, 128+1, &cb);
|
||||
GetData( 7, SQL_C_SLONG, (UCHAR*) &colInf[colNo].columnLength, 0, &cb);
|
||||
// BJO 991214 : SQL_C_SSHORT instead of SQL_C_SLONG, otherwise fails on Sparc (probably all 64 bit architectures)
|
||||
GetData( 8, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].bufferLength, 0, &cb);
|
||||
GetData( 8, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].bufferSize, 0, &cb);
|
||||
GetData( 9, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].decimalDigits,0, &cb);
|
||||
GetData(10, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].numPrecRadix, 0, &cb);
|
||||
GetData(11, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].nullable, 0, &cb);
|
||||
GetData(12, SQL_C_CHAR, (UCHAR*) colInf[colNo].remarks, 254+1, &cb);
|
||||
GetData(12, SQL_C_WXCHAR, (UCHAR*) colInf[colNo].remarks, 254+1, &cb);
|
||||
// Start Values for Primary/Foriegn Key (=No)
|
||||
colInf[colNo].PkCol = 0; // Primary key column 0=No; 1= First Key, 2 = Second Key etc.
|
||||
colInf[colNo].PkTableName[0] = 0; // Tablenames where Primary Key is used as a Foreign Key
|
||||
@@ -2629,12 +2639,12 @@ wxDbColInf *wxDb::GetColumns(const wxString &tableName, UWORD *numCols, const wx
|
||||
if (!wxStricmp(typeInfVarchar.TypeName, colInf[colNo].typeName))
|
||||
{
|
||||
#ifdef _IODBC_
|
||||
// IODBC does not return a correct columnSize, so we set
|
||||
// columnSize = bufferLength if no column size was returned
|
||||
// IODBC returns the columnSize in bufferLength.. (bug)
|
||||
if (colInf[colNo].columnSize < 1)
|
||||
// IODBC does not return a correct columnLength, so we set
|
||||
// columnLength = bufferSize if no column length was returned
|
||||
// IODBC returns the columnLength in bufferSize. (bug)
|
||||
if (colInf[colNo].columnLength < 1)
|
||||
{
|
||||
colInf[colNo].columnSize = colInf[colNo].bufferLength;
|
||||
colInf[colNo].columnLength = colInf[colNo].bufferSize;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2852,18 +2862,18 @@ wxDbColInf *wxDb::GetColumns(const wxString &tableName, int *numCols, const wxCh
|
||||
if (colNo < noCols) // Some extra error checking to prevent memory overwrites
|
||||
{
|
||||
// NOTE: Only the ODBC 1.x fields are retrieved
|
||||
GetData( 1, SQL_C_CHAR, (UCHAR*) colInf[colNo].catalog, 128+1, &cb);
|
||||
GetData( 2, SQL_C_CHAR, (UCHAR*) colInf[colNo].schema, 128+1, &cb);
|
||||
GetData( 3, SQL_C_CHAR, (UCHAR*) colInf[colNo].tableName, DB_MAX_TABLE_NAME_LEN+1, &cb);
|
||||
GetData( 4, SQL_C_CHAR, (UCHAR*) colInf[colNo].colName, DB_MAX_COLUMN_NAME_LEN+1, &cb);
|
||||
GetData( 1, SQL_C_WXCHAR, (UCHAR*) colInf[colNo].catalog, 128+1, &cb);
|
||||
GetData( 2, SQL_C_WXCHAR, (UCHAR*) colInf[colNo].schema, 128+1, &cb);
|
||||
GetData( 3, SQL_C_WXCHAR, (UCHAR*) colInf[colNo].tableName, DB_MAX_TABLE_NAME_LEN+1, &cb);
|
||||
GetData( 4, SQL_C_WXCHAR, (UCHAR*) colInf[colNo].colName, DB_MAX_COLUMN_NAME_LEN+1, &cb);
|
||||
GetData( 5, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].sqlDataType, 0, &cb);
|
||||
GetData( 6, SQL_C_CHAR, (UCHAR*) colInf[colNo].typeName, 128+1, &cb);
|
||||
GetData( 7, SQL_C_SLONG, (UCHAR*) &colInf[colNo].columnSize, 0, &cb);
|
||||
GetData( 8, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].bufferLength, 0, &cb);
|
||||
GetData( 6, SQL_C_WXCHAR, (UCHAR*) colInf[colNo].typeName, 128+1, &cb);
|
||||
GetData( 7, SQL_C_SLONG, (UCHAR*) &colInf[colNo].columnLength, 0, &cb);
|
||||
GetData( 8, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].bufferSize, 0, &cb);
|
||||
GetData( 9, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].decimalDigits,0, &cb);
|
||||
GetData(10, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].numPrecRadix, 0, &cb);
|
||||
GetData(11, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].nullable, 0, &cb);
|
||||
GetData(12, SQL_C_CHAR, (UCHAR*) colInf[colNo].remarks, 254+1, &cb);
|
||||
GetData(12, SQL_C_WXCHAR, (UCHAR*) colInf[colNo].remarks, 254+1, &cb);
|
||||
// Start Values for Primary/Foriegn Key (=No)
|
||||
colInf[colNo].PkCol = 0; // Primary key column 0=No; 1= First Key, 2 = Second Key etc.
|
||||
colInf[colNo].PkTableName[0] = 0; // Tablenames where Primary Key is used as a Foreign Key
|
||||
@@ -2871,12 +2881,12 @@ wxDbColInf *wxDb::GetColumns(const wxString &tableName, int *numCols, const wxCh
|
||||
colInf[colNo].FkTableName[0] = 0; // Foreign key table name
|
||||
|
||||
#ifdef _IODBC_
|
||||
// IODBC does not return a correct columnSize, so we set
|
||||
// columnSize = bufferLength if no column size was returned
|
||||
// IODBC returns the columnSize in bufferLength.. (bug)
|
||||
if (colInf[colNo].columnSize < 1)
|
||||
// IODBC does not return a correct columnLength, so we set
|
||||
// columnLength = bufferSize if no column length was returned
|
||||
// IODBC returns the columnLength in bufferSize. (bug)
|
||||
if (colInf[colNo].columnLength < 1)
|
||||
{
|
||||
colInf[colNo].columnSize = colInf[colNo].bufferLength;
|
||||
colInf[colNo].columnLength = colInf[colNo].bufferSize;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3178,8 +3188,8 @@ wxDbInf *wxDb::GetCatalog(const wxChar *userID)
|
||||
{
|
||||
if (pDbInf->numTables == 0)
|
||||
{
|
||||
GetData( 1, SQL_C_CHAR, (UCHAR*) pDbInf->catalog, 128+1, &cb);
|
||||
GetData( 2, SQL_C_CHAR, (UCHAR*) pDbInf->schema, 128+1, &cb);
|
||||
GetData( 1, SQL_C_WXCHAR, (UCHAR*) pDbInf->catalog, 128+1, &cb);
|
||||
GetData( 2, SQL_C_WXCHAR, (UCHAR*) pDbInf->schema, 128+1, &cb);
|
||||
}
|
||||
pDbInf->numTables++; // Counter for Tables
|
||||
} // if (pass == 1)
|
||||
@@ -3191,9 +3201,9 @@ wxDbInf *wxDb::GetCatalog(const wxChar *userID)
|
||||
noTab = 0;
|
||||
} // if (pDbInf->pTableInf == NULL) // Has the Table Array been created
|
||||
|
||||
GetData( 3, SQL_C_CHAR, (UCHAR*) (pDbInf->pTableInf+noTab)->tableName, DB_MAX_TABLE_NAME_LEN+1, &cb);
|
||||
GetData( 4, SQL_C_CHAR, (UCHAR*) (pDbInf->pTableInf+noTab)->tableType, 30+1, &cb);
|
||||
GetData( 5, SQL_C_CHAR, (UCHAR*) (pDbInf->pTableInf+noTab)->tableRemarks, 254+1, &cb);
|
||||
GetData( 3, SQL_C_WXCHAR, (UCHAR*) (pDbInf->pTableInf+noTab)->tableName, DB_MAX_TABLE_NAME_LEN+1, &cb);
|
||||
GetData( 4, SQL_C_WXCHAR, (UCHAR*) (pDbInf->pTableInf+noTab)->tableType, 30+1, &cb);
|
||||
GetData( 5, SQL_C_WXCHAR, (UCHAR*) (pDbInf->pTableInf+noTab)->tableRemarks, 254+1, &cb);
|
||||
|
||||
noTab++;
|
||||
} // if
|
||||
@@ -3286,10 +3296,10 @@ bool wxDb::Catalog(const wxChar *userID, const wxString &fileName)
|
||||
if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO)
|
||||
break;
|
||||
|
||||
GetData(3,SQL_C_CHAR, (UCHAR *) tblName, DB_MAX_TABLE_NAME_LEN+1, &cb);
|
||||
GetData(4,SQL_C_CHAR, (UCHAR *) colName, DB_MAX_COLUMN_NAME_LEN+1,&cb);
|
||||
GetData(3,SQL_C_WXCHAR, (UCHAR *) tblName, DB_MAX_TABLE_NAME_LEN+1, &cb);
|
||||
GetData(4,SQL_C_WXCHAR, (UCHAR *) colName, DB_MAX_COLUMN_NAME_LEN+1,&cb);
|
||||
GetData(5,SQL_C_SSHORT, (UCHAR *)&sqlDataType, 0, &cb);
|
||||
GetData(6,SQL_C_CHAR, (UCHAR *) typeName, sizeof(typeName), &cb);
|
||||
GetData(6,SQL_C_WXCHAR, (UCHAR *) typeName, sizeof(typeName), &cb);
|
||||
GetData(7,SQL_C_SLONG, (UCHAR *)&precision, 0, &cb);
|
||||
GetData(8,SQL_C_SLONG, (UCHAR *)&length, 0, &cb);
|
||||
|
||||
@@ -3479,25 +3489,25 @@ bool wxDb::TablePrivileges(const wxString &tableName, const wxString &priv, cons
|
||||
retcode = SQLFetch(hstmt);
|
||||
while (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
|
||||
{
|
||||
if (SQLGetData(hstmt, 1, SQL_C_CHAR, (UCHAR*) result.tableQual, sizeof(result.tableQual), &cbRetVal) != SQL_SUCCESS)
|
||||
if (SQLGetData(hstmt, 1, SQL_C_WXCHAR, (UCHAR*) result.tableQual, sizeof(result.tableQual), &cbRetVal) != SQL_SUCCESS)
|
||||
failed = true;
|
||||
|
||||
if (!failed && SQLGetData(hstmt, 2, SQL_C_CHAR, (UCHAR*) result.tableOwner, sizeof(result.tableOwner), &cbRetVal) != SQL_SUCCESS)
|
||||
if (!failed && SQLGetData(hstmt, 2, SQL_C_WXCHAR, (UCHAR*) result.tableOwner, sizeof(result.tableOwner), &cbRetVal) != SQL_SUCCESS)
|
||||
failed = true;
|
||||
|
||||
if (!failed && SQLGetData(hstmt, 3, SQL_C_CHAR, (UCHAR*) result.tableName, sizeof(result.tableName), &cbRetVal) != SQL_SUCCESS)
|
||||
if (!failed && SQLGetData(hstmt, 3, SQL_C_WXCHAR, (UCHAR*) result.tableName, sizeof(result.tableName), &cbRetVal) != SQL_SUCCESS)
|
||||
failed = true;
|
||||
|
||||
if (!failed && SQLGetData(hstmt, 4, SQL_C_CHAR, (UCHAR*) result.grantor, sizeof(result.grantor), &cbRetVal) != SQL_SUCCESS)
|
||||
if (!failed && SQLGetData(hstmt, 4, SQL_C_WXCHAR, (UCHAR*) result.grantor, sizeof(result.grantor), &cbRetVal) != SQL_SUCCESS)
|
||||
failed = true;
|
||||
|
||||
if (!failed && SQLGetData(hstmt, 5, SQL_C_CHAR, (UCHAR*) result.grantee, sizeof(result.grantee), &cbRetVal) != SQL_SUCCESS)
|
||||
if (!failed && SQLGetData(hstmt, 5, SQL_C_WXCHAR, (UCHAR*) result.grantee, sizeof(result.grantee), &cbRetVal) != SQL_SUCCESS)
|
||||
failed = true;
|
||||
|
||||
if (!failed && SQLGetData(hstmt, 6, SQL_C_CHAR, (UCHAR*) result.privilege, sizeof(result.privilege), &cbRetVal) != SQL_SUCCESS)
|
||||
if (!failed && SQLGetData(hstmt, 6, SQL_C_WXCHAR, (UCHAR*) result.privilege, sizeof(result.privilege), &cbRetVal) != SQL_SUCCESS)
|
||||
failed = true;
|
||||
|
||||
if (!failed && SQLGetData(hstmt, 7, SQL_C_CHAR, (UCHAR*) result.grantable, sizeof(result.grantable), &cbRetVal) != SQL_SUCCESS)
|
||||
if (!failed && SQLGetData(hstmt, 7, SQL_C_WXCHAR, (UCHAR*) result.grantable, sizeof(result.grantable), &cbRetVal) != SQL_SUCCESS)
|
||||
failed = true;
|
||||
|
||||
if (failed)
|
||||
@@ -4186,8 +4196,8 @@ int wxDbCreateDataSource(const wxString &driverName, const wxString &dsn, const
|
||||
|
||||
|
||||
/********** wxDbGetDataSource() **********/
|
||||
bool wxDbGetDataSource(HENV henv, wxChar *Dsn, SWORD DsnMax, wxChar *DsDesc,
|
||||
SWORD DsDescMax, UWORD direction)
|
||||
bool wxDbGetDataSource(HENV henv, wxChar *Dsn, SWORD DsnMaxLength, wxChar *DsDesc,
|
||||
SWORD DsDescMaxLength, UWORD direction)
|
||||
/*
|
||||
* Dsn and DsDesc will contain the data source name and data source
|
||||
* description upon return
|
||||
@@ -4195,8 +4205,8 @@ bool wxDbGetDataSource(HENV henv, wxChar *Dsn, SWORD DsnMax, wxChar *DsDesc,
|
||||
{
|
||||
SWORD cb1,cb2;
|
||||
|
||||
if (SQLDataSources(henv, direction, (SQLTCHAR FAR *) Dsn, DsnMax, &cb1,
|
||||
(SQLTCHAR FAR *) DsDesc, DsDescMax, &cb2) == SQL_SUCCESS)
|
||||
if (SQLDataSources(henv, direction, (SQLTCHAR FAR *) Dsn, DsnMaxLength*sizeof(wxChar), &cb1,
|
||||
(SQLTCHAR FAR *) DsDesc, DsDescMaxLength*sizeof(wxChar), &cb2) == SQL_SUCCESS)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
@@ -434,7 +434,7 @@ void wxDbTable::setCbValueForColumn(int columnIndex)
|
||||
if (colDefs[columnIndex].Null)
|
||||
colDefs[columnIndex].CbValue = SQL_NULL_DATA;
|
||||
else
|
||||
if (colDefs[columnIndex].SqlCtype == SQL_C_CHAR)
|
||||
if (colDefs[columnIndex].SqlCtype == SQL_C_WXCHAR)
|
||||
colDefs[columnIndex].CbValue = SQL_NTS;
|
||||
else
|
||||
colDefs[columnIndex].CbValue = SQL_LEN_DATA_AT_EXEC(colDefs[columnIndex].SzDataObj);
|
||||
@@ -779,7 +779,7 @@ bool wxDbTable::Open(bool checkPrivileges, bool checkTableExists)
|
||||
// reliable!
|
||||
if (// *(pDb->dbInf.accessibleTables) == 'N' &&
|
||||
!pDb->TablePrivileges(tableName,wxT("SELECT"), pDb->GetUsername(), pDb->GetUsername(), tablePath))
|
||||
s = wxT("Current logged in user does not have sufficient privileges to access this table.\n");
|
||||
s = wxT("Connecting user does not have sufficient privileges to access this table.\n");
|
||||
}
|
||||
|
||||
if (!s.IsEmpty())
|
||||
@@ -998,7 +998,7 @@ void wxDbTable::BuildDeleteStmt(wxString &pSqlStmt, int typeOfDel, const wxStrin
|
||||
// Get the ROWID value. If not successful retreiving the ROWID,
|
||||
// simply fall down through the code and build the WHERE clause
|
||||
// based on the key fields.
|
||||
if (SQLGetData(hstmt, (UWORD)(noCols+1), SQL_C_CHAR, (UCHAR*) rowid, wxDB_ROWID_LEN, &cb) == SQL_SUCCESS)
|
||||
if (SQLGetData(hstmt, (UWORD)(noCols+1), SQL_C_WXCHAR, (UCHAR*) rowid, sizeof(rowid), &cb) == SQL_SUCCESS)
|
||||
{
|
||||
pSqlStmt += wxT("ROWID = '");
|
||||
pSqlStmt += rowid;
|
||||
@@ -1216,7 +1216,7 @@ void wxDbTable::BuildUpdateStmt(wxString &pSqlStmt, int typeOfUpd, const wxStrin
|
||||
// Get the ROWID value. If not successful retreiving the ROWID,
|
||||
// simply fall down through the code and build the WHERE clause
|
||||
// based on the key fields.
|
||||
if (SQLGetData(hstmt, (UWORD)(noCols+1), SQL_C_CHAR, (UCHAR*) rowid, wxDB_ROWID_LEN, &cb) == SQL_SUCCESS)
|
||||
if (SQLGetData(hstmt, (UWORD)(noCols+1), SQL_C_WXCHAR, (UCHAR*) rowid, sizeof(rowid), &cb) == SQL_SUCCESS)
|
||||
{
|
||||
pSqlStmt += wxT("ROWID = '");
|
||||
pSqlStmt += rowid;
|
||||
@@ -1283,7 +1283,7 @@ void wxDbTable::BuildWhereClause(wxString &pWhereClause, int typeOfWhere,
|
||||
}
|
||||
pWhereClause += pDb->SQLColumnName(colDefs[colNo].ColName);
|
||||
|
||||
if (useLikeComparison && (colDefs[colNo].SqlCtype == SQL_C_CHAR))
|
||||
if (useLikeComparison && (colDefs[colNo].SqlCtype == SQL_C_WXCHAR))
|
||||
pWhereClause += wxT(" LIKE ");
|
||||
else
|
||||
pWhereClause += wxT(" = ");
|
||||
@@ -1291,6 +1291,8 @@ void wxDbTable::BuildWhereClause(wxString &pWhereClause, int typeOfWhere,
|
||||
switch(colDefs[colNo].SqlCtype)
|
||||
{
|
||||
case SQL_C_CHAR:
|
||||
case SQL_C_WCHAR:
|
||||
//case SQL_C_WXCHAR: SQL_C_WXCHAR is covered by either SQL_C_CHAR or SQL_C_WCHAR
|
||||
colValue.Printf(wxT("'%s'"), (UCHAR FAR *) colDefs[colNo].PtrDataObj);
|
||||
break;
|
||||
case SQL_C_SHORT:
|
||||
@@ -1395,7 +1397,7 @@ bool wxDbTable::CreateTable(bool attemptDrop)
|
||||
switch(colDefs[i].DbDataType)
|
||||
{
|
||||
case DB_DATA_TYPE_VARCHAR:
|
||||
cout << pDb->GetTypeInfVarchar().TypeName << wxT("(") << colDefs[i].SzDataObj << wxT(")");
|
||||
cout << pDb->GetTypeInfVarchar().TypeName << wxT("(") << (int)(colDefs[i].SzDataObj / sizeof(wxChar)) << wxT(")");
|
||||
break;
|
||||
case DB_DATA_TYPE_INTEGER:
|
||||
cout << pDb->GetTypeInfInteger().TypeName;
|
||||
@@ -1457,7 +1459,7 @@ bool wxDbTable::CreateTable(bool attemptDrop)
|
||||
// colDefs[i].DbDataType == DB_DATA_TYPE_BLOB)
|
||||
{
|
||||
wxString s;
|
||||
s.Printf(wxT("(%d)"), colDefs[i].SzDataObj);
|
||||
s.Printf(wxT("(%d)"), (int)(colDefs[i].SzDataObj / sizeof(wxChar)));
|
||||
sqlStmt += s;
|
||||
}
|
||||
|
||||
@@ -1531,7 +1533,7 @@ bool wxDbTable::CreateTable(bool attemptDrop)
|
||||
colDefs[i].DbDataType == DB_DATA_TYPE_VARCHAR)
|
||||
{
|
||||
wxString s;
|
||||
s.Printf(wxT("(%d)"), colDefs[i].SzDataObj);
|
||||
s.Printf(wxT("(%d)"), (int)(colDefs[i].SzDataObj / sizeof(wxChar)));
|
||||
sqlStmt += s;
|
||||
}
|
||||
}
|
||||
@@ -1673,7 +1675,7 @@ bool wxDbTable::CreateIndex(const wxString &idxName, bool unique, UWORD noIdxCol
|
||||
if (found)
|
||||
{
|
||||
ok = pDb->ModifyColumn(tableName, pIdxDefs[i].ColName,
|
||||
colDefs[j].DbDataType, colDefs[j].SzDataObj,
|
||||
colDefs[j].DbDataType, (int)(colDefs[j].SzDataObj / sizeof(wxChar)),
|
||||
wxT("NOT NULL"));
|
||||
|
||||
if (!ok)
|
||||
@@ -1735,7 +1737,7 @@ bool wxDbTable::CreateIndex(const wxString &idxName, bool unique, UWORD noIdxCol
|
||||
if ( colDefs[j].DbDataType == DB_DATA_TYPE_VARCHAR)
|
||||
{
|
||||
wxString s;
|
||||
s.Printf(wxT("(%d)"), colDefs[i].SzDataObj);
|
||||
s.Printf(wxT("(%d)"), (int)(colDefs[i].SzDataObj / sizeof(wxChar)));
|
||||
sqlStmt += s;
|
||||
}
|
||||
}
|
||||
@@ -2090,6 +2092,8 @@ bool wxDbTable::IsColNull(UWORD colNo) const
|
||||
switch(colDefs[colNo].SqlCtype)
|
||||
{
|
||||
case SQL_C_CHAR:
|
||||
case SQL_C_WCHAR:
|
||||
//case SQL_C_WXCHAR: SQL_C_WXCHAR is covered by either SQL_C_CHAR or SQL_C_WCHAR
|
||||
return(((UCHAR FAR *) colDefs[colNo].PtrDataObj)[0] == 0);
|
||||
case SQL_C_SSHORT:
|
||||
return(( *((SWORD *) colDefs[colNo].PtrDataObj)) == 0);
|
||||
@@ -2173,6 +2177,8 @@ void wxDbTable::ClearMemberVar(UWORD colNo, bool setToNull)
|
||||
switch(colDefs[colNo].SqlCtype)
|
||||
{
|
||||
case SQL_C_CHAR:
|
||||
case SQL_C_WCHAR:
|
||||
//case SQL_C_WXCHAR: SQL_C_WXCHAR is covered by either SQL_C_CHAR or SQL_C_WCHAR
|
||||
((UCHAR FAR *) colDefs[colNo].PtrDataObj)[0] = 0;
|
||||
break;
|
||||
case SQL_C_SSHORT:
|
||||
@@ -2271,7 +2277,7 @@ void wxDbTable::SetColDefs(UWORD index, const wxString &fieldName, int dataType,
|
||||
colDefs[index].DbDataType = dataType;
|
||||
colDefs[index].PtrDataObj = pData;
|
||||
colDefs[index].SqlCtype = cType;
|
||||
colDefs[index].SzDataObj = size;
|
||||
colDefs[index].SzDataObj = size; //TODO: glt ??? * sizeof(wxChar) ???
|
||||
colDefs[index].KeyField = keyField;
|
||||
colDefs[index].DerivedCol = derivedCol;
|
||||
// Derived columns by definition would NOT be "Insertable" or "Updateable"
|
||||
@@ -2309,13 +2315,13 @@ wxDbColDataPtr* wxDbTable::SetColDefs(wxDbColInf *pColInfs, UWORD numCols)
|
||||
switch (pColInfs[index].dbDataType)
|
||||
{
|
||||
case DB_DATA_TYPE_VARCHAR:
|
||||
pColDataPtrs[index].PtrDataObj = new wxChar[pColInfs[index].bufferLength+1];
|
||||
pColDataPtrs[index].SzDataObj = pColInfs[index].columnSize;
|
||||
pColDataPtrs[index].SqlCtype = SQL_C_CHAR;
|
||||
pColDataPtrs[index].PtrDataObj = new wxChar[pColInfs[index].bufferSize+(1*sizeof(wxChar))];
|
||||
pColDataPtrs[index].SzDataObj = pColInfs[index].bufferSize+(1*sizeof(wxChar));
|
||||
pColDataPtrs[index].SqlCtype = SQL_C_WXCHAR;
|
||||
break;
|
||||
case DB_DATA_TYPE_INTEGER:
|
||||
// Can be long or short
|
||||
if (pColInfs[index].bufferLength == sizeof(long))
|
||||
if (pColInfs[index].bufferSize == sizeof(long))
|
||||
{
|
||||
pColDataPtrs[index].PtrDataObj = new long;
|
||||
pColDataPtrs[index].SzDataObj = sizeof(long);
|
||||
@@ -2330,7 +2336,7 @@ wxDbColDataPtr* wxDbTable::SetColDefs(wxDbColInf *pColInfs, UWORD numCols)
|
||||
break;
|
||||
case DB_DATA_TYPE_FLOAT:
|
||||
// Can be float or double
|
||||
if (pColInfs[index].bufferLength == sizeof(float))
|
||||
if (pColInfs[index].bufferSize == sizeof(float))
|
||||
{
|
||||
pColDataPtrs[index].PtrDataObj = new float;
|
||||
pColDataPtrs[index].SzDataObj = sizeof(float);
|
||||
@@ -2488,7 +2494,7 @@ bool wxDbTable::Refresh(void)
|
||||
// Get the ROWID value. If not successful retreiving the ROWID,
|
||||
// simply fall down through the code and build the WHERE clause
|
||||
// based on the key fields.
|
||||
if (SQLGetData(hstmt, (UWORD)(noCols+1), SQL_C_CHAR, (UCHAR*) rowid, wxDB_ROWID_LEN, &cb) == SQL_SUCCESS)
|
||||
if (SQLGetData(hstmt, (UWORD)(noCols+1), SQL_C_WXCHAR, (UCHAR*) rowid, sizeof(rowid), &cb) == SQL_SUCCESS)
|
||||
{
|
||||
whereClause += pDb->SQLTableName(queryTableName);
|
||||
// whereClause += queryTableName;
|
||||
@@ -2739,7 +2745,7 @@ void wxDbTable::SetCol(const int colNo, const wxVariant val)
|
||||
case SQL_VARCHAR:
|
||||
csstrncpyt((wxChar *)(colDefs[colNo].PtrDataObj),
|
||||
val.GetString().c_str(),
|
||||
colDefs[colNo].SzDataObj-1);
|
||||
colDefs[colNo].SzDataObj-1); //TODO: glt ??? * sizeof(wxChar) ???
|
||||
break;
|
||||
case SQL_C_LONG:
|
||||
case SQL_C_SLONG:
|
||||
|
Reference in New Issue
Block a user