Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / error with source code

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. error with source code
#7157
Posted by: sjoyous 2005-10-04 20:20:36
hi,
 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)
                continue;
            // If there is more than 1 column, join them with the keyword "AND"
            if (moreThanOneColumn)
                pWhereClause += wxT(" AND ");
            else
                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 ");
            else
                pWhereClause += wxT(" = ");
            switch(colDefs.SqlCtype)
            {
                case SQL_C_CHAR:
                    colValue.Printf(wxT("'%s'"), (UCHAR FAR *) colDefs.PtrDataObj);
                    break;
                case SQL_C_SSHORT:
                    colValue.Printf(wxT("%hi"), *((SWORD *) colDefs.PtrDataObj));
                    break;
                case SQL_C_USHORT:
                    colValue.Printf(wxT("%hu"), *((UWORD *) colDefs.PtrDataObj));
                    break;
                case SQL_C_SLONG:
                    colValue.Printf(wxT("%li"), *((SDWORD *) colDefs.PtrDataObj));
                    break;
                case SQL_C_ULONG:
                    colValue.Printf(wxT("%lu"), *((UDWORD *) colDefs.PtrDataObj));
                    break;
                case SQL_C_FLOAT:
                    colValue.Printf(wxT("%.6f"), *((SFLOAT *) colDefs.PtrDataObj));
                    break;
                case SQL_C_DOUBLE:
                    colValue.Printf(wxT("%.6f"), *((SDOUBLE *) colDefs.PtrDataObj));
                    break;
            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
掌柜推荐
 
 
¥738.00 ·
 
 
¥1,480.00 ·
 
 
¥397.00 ·
 
 
¥950.00 ·
 
 
¥264.00 ·
 
 
¥1,005.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0