条件表达式中的数据类型不匹配

条件表达式中的数据类型不匹配

本文介绍了vc ++ .net中条件表达式中的数据类型不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有一个ms访问表 TableRegistration(PersonID为NUMBER,名称为TEXT) PersonID名称 ----------------- 1 abc 2 xyz b $ b 尝试 { int ss = 1 ; cmd.Format( 来自TableRegistration的SELECT *,其中PersonID ='%d', SS); // m_recordset.Open(dbOpenTable,cmd,dbSeeChanges); m_recordset 。开(AFX_DAO_USE_DEFAULT_TYPE,CMD,dbSeeChanges); } catch (CDaoException * e) { AfxMessageBox(e-> m_pErrorInfo-> m_strDescription, MB_ICONEXCLAMATION); e->删除(); } 它会产生异常 条件表达式中的数据类型不匹配 如何解决它来自TableRegistration的SELECT * =''%d'',ss); 您可以删除查询中的引号,然后重试 - >> SELECT *来自TableRegistration,其中PersonID =%d,SS); I have a table in ms accessTableRegistration(PersonID as NUMBER,Name as TEXT)PersonID Name-----------------1 abc2 xyztry{int ss=1;cmd.Format("SELECT * from TableRegistration where PersonID='%d'",ss); //m_recordset.Open(dbOpenTable,cmd,dbSeeChanges); m_recordset.Open(AFX_DAO_USE_DEFAULT_TYPE,cmd,dbSeeChanges);}catch(CDaoException* e){AfxMessageBox(e->m_pErrorInfo->m_strDescription, MB_ICONEXCLAMATION);e->Delete();}it generate exception"data type mismatch in criteria expression"How to solve it? 解决方案 SELECT * from TableRegistration where PersonID=''%d''",ss);You can remove the quotes in the query and try again ->SELECT * from TableRegistration where PersonID=%d",ss); 这篇关于vc ++ .net中条件表达式中的数据类型不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-13 07:51