Exemplo n.º 1
0
///////////////////////////////////////////////////////
//
//	Name: GetADOError
//	Params: Conn1 - connection pointer
//	Returns: ADO error string
//	Description: determines ADO error(s) that occurred 
///////////////////////////////////////////////////////
std::string GetADOError(_ConnectionPtr Conn1)
{
	USES_CONVERSION;
   ErrorsPtr   Errs1 = NULL;
    ErrorPtr    Err1  = NULL;

	std::string sRet("ADO Error. Description: ");
    long        nCount;

   try
    {
	    if( Conn1 == NULL ) return sRet + (std::string)"NULL Connection";
  
		// Enumerate Errors Collection and display properties of each object.
        Errs1  = Conn1->GetErrors();
        nCount = Errs1->GetCount();

        // Loop through Errors Collection
        for( long i = 0; i < nCount; i++ )
        {
            // Get Error Item
            Err1 = Errs1->GetItem((_variant_t)((long)i) );
			sRet += (std::string)" Description: " + (std::string)OLE2T(Err1->GetDescription());
		}
	
		if( Errs1 != NULL )  Errs1->Release(); 
		if( Err1  != NULL )  Err1->Release();  
   }
   catch(...)
   {
	   sRet += " Unknown Error";
   }
	
   return sRet;
}
Exemplo n.º 2
0
bool RxADO::SetConnection(CString LinkString)
{
	::CoInitialize(NULL);
	cnn=NULL;
	cnn.CreateInstance(__uuidof(Connection));
	cnn->ConnectionString=(_bstr_t)LinkString;
	try{
		cnn->Open(L"",L"",L"",adCmdUnspecified);
	}
	catch(_com_error& e)
	{
		ErrorsPtr pErrors=cnn->GetErrors();
		if (pErrors->GetCount()==0)
		{	
			CString ErrMsg=e.ErrorMessage();
			MessageBox(NULL,"·¢Éú´íÎó:\n\n"+ErrMsg,"ϵͳÌáʾ",MB_OK|MB_ICONEXCLAMATION);	
			return false;
		}
		else
		{
			for (int i=0;i<pErrors->GetCount();i++)
			{
				_bstr_t desc=pErrors->GetItem((long)i)->GetDescription();
				MessageBox(NULL,"·¢Éú´íÎó:\n\n"+desc,"ϵͳÌáʾ",MB_OK|MB_ICONEXCLAMATION);
				return false;
			}
		}	
	}
	return true;
}
Exemplo n.º 3
0
void RxADO::GetADOErrors(_com_error eErrors)
{
	ErrorsPtr pErrors=cnn->GetErrors();
	if (pErrors->GetCount()==0)	
		MessageBox(NULL,eErrors.ErrorMessage(),"´í  Îó",MB_OK|MB_ICONEXCLAMATION);	
	else
	{
		for (int i=0;i<pErrors->GetCount();i++)
		{
			_bstr_t desc=pErrors->GetItem((long)i)->GetDescription();
			MessageBox(NULL,desc,"´í  Îó",MB_OK|MB_ICONEXCLAMATION);
		}
	}
}