if(!recset) {
AfxMessageBox (L" Login Suucessfully ");
thrdlg dil;
}
else
{
AfxMessageBox(L" UserID and Password is wrong!! ");
}
Firstly the logic of your if statement is wrong; if the recset object exists you post the error message. And secondly, and more importantly, you are ignoring the actual return value from the Open call. You need to capture the result of the Open call and test that. So your code should be:
bool bSuccess = recset.Open(CRecordset::forwardOnly,SqlString,CRecordset::readOnly);
if (bSuccess)
{
AfxMessageBox (L" Login Suucessfully ");
thrdlg dil;
}
else
{
AfxMessageBox(L" UserID and Password is wrong!! ");
}