Display detailed ADO error message

xiaoxiao2021-03-06  95

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);

转载请注明原文地址:https://www.9cbs.com/read-123320.html

New Post(0)