1、增加变量定义:
_CommandPtr m_pCommand;
2、增加以下语句进行判断,此处判断的是身份证号字段,是否和strId的值一致,
strId的值为CString,在执行之前赋值。
CString str;
_RecordsetPtr m_tmppSet = NULL;str.Format("select * from DemoTable where 身份证号='%s'",strId);
m_pCommand->CommandText = (_bstr_t)str;
m_tmppSet = m_pCommand->Execute(NULL, NULL,adCmdText);
if (m_tmppSet->BOF || m_tmppSet->adoEOF)
{
AfxMessageBox("该用户不存在");
m_tmppSet->Close();