When we use ADO to connect data, we often have some exceptions, and use _COM_ERROR :: ErrorMessage () sometimes given the error message too nor intuitive. Therefore, I give the following code to get a more comprehensive and intuitive error message.
Long lerrcount = pconn-> getRrors () -> getCount (); // PConn is your connection variable, _connectionPTR
_BSTR_T ADD;
CString Strerrmsg, StrtMP;
For (Short I = 0; I
{
Add = PCONN-> getRrors () -> GetItem (_VARIANT_T (SHORT) I)) -> getdescription ();
STRTMP = (char *) add;
STRRMSG = strtmp;
}
AfxMessageBox (STRRMSG);