Verifying an unsuccessful failover

If the connection to the secondary server is not established, the ASE OLE DB Driver also returns “E_FAIL” for the function return HRESULT. However, the dwMinor field in ERRORINFO (returned from IErrorRecords::GetBasicErrorInfo) should be “30131”, and the description returned from IErrorInfo::GetDescription should be:

“Connection to Sybase server has been lost, connection
to the next available HA server also failed. All
transactions have been rolled back.”

Sample code for checking failover

The following code snippet shows how to code for a failover:

/* Declare required variables */
...
/* Open Database connection */
...
/* Perform a transaction */
...
/*Check HRESULT  and dwMinor in ERRORINFO, handle
   failover */
if (FAILED(hr))
{
   IErrorInfo* pIErrorInfo;
   GetErrorInfo(0, &pIErrorInfo);
   IErrorRecords * pIErrorRecords;
   HRESULT hr1 = pIErrorInfo->QueryInterface(
     IID_IErrorRecords,(void **)&pIErrorRecords);

   if (SUCCEEDED(hr1))
   {
      ERRORINFO errorInfo;
     pIErrorRecords->GetBasicErrorInfo(0,
        &errorInfo);
     pIErrorRecords->Release();			 
     if (errorInfo.dwMinor == 30130)
     {
        //successful failover,
        //retry the transaction
      }
   }
}