Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

sp_OAMethod Expand / Collapse
Author
Message
Posted Sunday, January 20, 2013 2:23 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 4:25 AM
Points: 143, Visits: 653
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?
Post #1409260
Posted Sunday, January 20, 2013 5:30 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Thursday, November 13, 2014 4:47 PM
Points: 459, Visits: 283
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
Post #1409268
Posted Sunday, January 20, 2013 8:08 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 6:32 AM
Points: 7,135, Visits: 12,745
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
Post #1409278
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse