sp_OAMethod

  • hello all.

    I use this:declare @h int,@objDBC int

    EXEC sp_OACreate 'ADODB.Connection', @objDBC OUT

    --------@objDBC =16711422

    EXEC @h=sp_OASetProperty 16711422,

    'ConnectionString', 'Driver={SQL Server};

    Server=WIN-00UO3RQ0BM3;

    Database=MaliGilan;

    trusted_Connection=Yes'

    EXEC @h=sp_OAMethod 16711422, 'Open'

    print @h

    this have to returns zero but returns -2147467259.

    please tell me why this dosen't return zero?

  • Have you enabled the OA in the server? Please check this via sp_configure:

    sp_configure 'show advanced options',1

    GO

    reconfigure

    GO

    sp_configure 'Ole Automation Procedures'

    You should see the run_value as 1. If not - set it to 1 and check the code one more time

    Kindest Regards,

    Damian Widera
    SQL Server MVP,
    MCT, MCSE Data Platform, MCSD.NET

  • You could also consider switching to use a Linked Server to connect to a remote SQL Server instead of using the OLE Automation routines.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply