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, March 05, 2014 10:52 PM
Points: 129, Visits: 478
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: Sunday, March 30, 2014 11:40 AM
Points: 459, Visits: 256
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: Thursday, April 10, 2014 10:17 AM
Points: 7,070, Visits: 12,522
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

Believe you can and you're halfway there. --Theodore Roosevelt

Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein

The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein

1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
Post #1409278
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse