Sunday, February 19, 2012

Data type mismatch in criteria expression.

Hi,

I am santosh sending this mail regards database errorin vc++ 6.0 application . actually I am trying to convert old MS SQL server database to MS Access so what are the changes should I do in vc++ source code so it can work fine with MS Access. I am trying but it giving error on this statement as follows :-

strSQLString.MakeUpper();

ReturnCode = SQLExecDirect(m_hstmt,(UCHAR*)((LPCTSTR)strSQLString),SQL_NTS);

if (ReturnCode)

{

CDBException* pDBEx = new CDBException();

pDBEx->BuildErrorString(m_pDatabase,m_hstmt);

throw ( pDBEx);

return 0;

}

And this is sql statement witch is storing data in data type ofCStringstrSQLString;and the statement is as follows:-

strSQLString.Format("SELECT TOP %d MESSAGEID, MOBILENUMBER,MESSAGETEXT, SENDERID, RECDDATETIME, SENDDATETIME, SUBSCUSERID, SUBSCID, MESSAGESTATUS, RETURNCODE , PRIORITYLEVEL, VALIDITYDATETIME, MCL,CONFIRMREQD,DATAENCODING FROM SMSMESSAGES WHERE MESSAGESTATUS = 0", nRowsToFetch );

so I getting error likeby this in Debug mode throw (pDBEx);

Data type mismatch in criteria expression.

State:22005,Native:-3030,Origin:[Microsoft][ODBC Microsoft Access Driver]

And I am connecting throw database by DSN .

Please tell me the way for this is possible or not I am waiting for response .

Best regards,

S. Santosh Naidu

Is SMSMESSAGES.MESSAGESTATUS a varchar? If so, you'd want to rewrite your where clause to WHERE MESSAGESTATUS = '0' or similar. Send along your DDL for the table if this isn't the problem.

Hope this helps,
Josh Lindenmuth

No comments:

Post a Comment