Guidance Forums / wxWidgets (wxWindows) in C++ / error with source code

Search 搜索
Home Home

Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. error with source code
Posted by: sjoyous 2005-10-04 20:20:36
 i am using wxWindows-2.4.2 and i am developing the attendance system using smart card, i am using mysql as back hand. To connect with database i am using ODBC driver.
my problem:
 when i am trying to access the table having column with datatype as DATE.
for this table i am using the wxDbTable class to create the table object for the sql database table. by using this object i am specifying column information by using SetColDef() function of wxDbTable class. in this i have to specify all constraints of the column, in this for data type i have used the identifier SQL_C_DATE.
now when i am trying to delete any record using Delete() function of the wxDbTable class, in this it first build the where clause, in which according to the identifier it will build the where statement.
in source code it just like following

file name is : dbtable.cpp

for (i = 0; i < noCols; i++)
        // Determine if this column should be included  in the WHERE clause
        if ((typeOfWhere == DB_WHERE_KEYFIELDS && colDefs.KeyField) ||
             (typeOfWhere == DB_WHERE_MATCHING  && (!IsColNull(i))))
            // Skip over timestamp columns
            if (colDefs.SqlCtype == SQL_C_TIMESTAMP)
            // If there is more than 1 column, join them with the keyword "AND"
            if (moreThanOneColumn)
                pWhereClause += wxT(" AND ");
                moreThanOneColumn = TRUE;
            // Concatenate where phrase for the column
            if (qualTableName.Length())
                pWhereClause += pDb->SQLTableName(qualTableName);
//                pWhereClause += qualTableName;
                pWhereClause += wxT(".");
            pWhereClause += pDb->SQLColumnName(colDefs.ColName);
//            pWhereClause += colDefs.ColName;
            if (useLikeComparison && (colDefs.SqlCtype == SQL_C_CHAR))
                pWhereClause += wxT(" LIKE ");
                pWhereClause += wxT(" = ");
                case SQL_C_CHAR:
                    colValue.Printf(wxT("'%s'"), (UCHAR FAR *) colDefs.PtrDataObj);
                case SQL_C_SSHORT:
                    colValue.Printf(wxT("%hi"), *((SWORD *) colDefs.PtrDataObj));
                case SQL_C_USHORT:
                    colValue.Printf(wxT("%hu"), *((UWORD *) colDefs.PtrDataObj));
                case SQL_C_SLONG:
                    colValue.Printf(wxT("%li"), *((SDWORD *) colDefs.PtrDataObj));
                case SQL_C_ULONG:
                    colValue.Printf(wxT("%lu"), *((UDWORD *) colDefs.PtrDataObj));
                case SQL_C_FLOAT:
                    colValue.Printf(wxT("%.6f"), *((SFLOAT *) colDefs.PtrDataObj));
                case SQL_C_DOUBLE:
                    colValue.Printf(wxT("%.6f"), *((SDOUBLE *) colDefs.PtrDataObj));
            case SQL_C_DATE:
               colValue.Printf(wxT("'%s'"), ((UCHAR FAR *) colDefs.PtrDataObj);
            pWhereClause += colValue;

so now my problem is that ther is no identifier available for the SQL_C_DATE type in the above case statement so when the column having datatype as SQL_C_TYPE comes in the switch statement it does not match with any case values so in the colvalue variable privious value is remains , so it build just like "delete from tablename where emp_code = 42 and from_dt = 42". in this it has to like "delete from tablename where emp_code = 42 and from_dt = '2005-09-01'"
   so is there any solution for this , if you find then please reply as soon as possible because it is very urgent.
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
© Wed 2022-8-10  Guidance Laboratory Inc. Hits:0