Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2004

    Unanswered: attempts to insert duplicate key

    I'm using Sybase.ASEOLEDBProvider.2 version 2.7 for all database access-using OLEDB from VC++ and use CDynamicParameterAccessor: CCommand<CDynamicParameterAccessor, CRowset, CMultipleResults> cmdRS

    The problem is when the stored proc attempts to insert duplicate key.

    Till version 2.5 it used to return "Command has been aborted" as error when checked using GetErrorInfo() after execution.

    But with version 2.7 of the OLEDB provider, it doesn't raise any error. Even if GetErrorInfo is called to check if anything has gone wrong after executing the stored proc it returns a NULL pointer which means no errors have occurred.

    But when I run the same stored proc using Visual Basic, it doesn't raise any error but the ADODB.Connection errors are populated correctly as "Attempt to insert duplicate.... and Command has been aborted"

    It was reported as bug in version 2.5 of ASEOLEDBProvider and fixed in 2.7

    Is anyone aware of the workaround or solution other than explicitly checking for duplicate row in every stored proc?

  2. #2
    Join Date
    Aug 2004
    I found the workaround for the problem mentioned above.

    Instead of using CCommand<CDynamicParameterAccessor, CRowset, CMultipleResults> i use now CNoMuiltpleResults.

    This allows to catch the Sybase Native Errors like "attempt to insert duplicate key", ...

    But when u execute the stored proc the return HRESULT will be S_OK. You should explicitly check for errors using GetErrorInfo().

    This solves the problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts