SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


sp_OAMethod


sp_OAMethod

Author
Message
elham_azizi_62
elham_azizi_62
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1189 Visits: 820
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?
Damian Widera-396333
Damian Widera-396333
Mr or Mrs. 500
Mr or Mrs. 500 (578 reputation)Mr or Mrs. 500 (578 reputation)Mr or Mrs. 500 (578 reputation)Mr or Mrs. 500 (578 reputation)Mr or Mrs. 500 (578 reputation)Mr or Mrs. 500 (578 reputation)Mr or Mrs. 500 (578 reputation)Mr or Mrs. 500 (578 reputation)

Group: General Forum Members
Points: 578 Visits: 321
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
Orlando Colamatteo
Orlando Colamatteo
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39794 Visits: 14412
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search