Click here to Skip to main content
15,886,570 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I have a table in ms access
TableRegistration(PersonID as NUMBER,Name as TEXT)

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


C++
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?
Posted

1 solution

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);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900