vc ++ .net中条件表达式中的数据类型不匹配 [英] data type mismatch in criteria expression in vc++.net

查看:89
本文介绍了vc ++ .net中条件表达式中的数据类型不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ms访问表

TableRegistration(PersonID为NUMBER,名称为TEXT)



PersonID名称

-----------------

1 abc

2 xyz

< br $> 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 access
TableRegistration(PersonID as NUMBER,Name as TEXT)

PersonID Name
-----------------
1 abc
2 xyz


try
{
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中条件表达式中的数据类型不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆