General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
I am trying this code in the query analyzer but for some reaseon never get connected to the remote pc.
it remains in the loop.
I can connect with a client program, setting the same properties
can someone tell me why can i connect?
DECLARE @object int
DECLARE @hr int
DECLARE @i int
DECLARE @src varchar(255), @desc varchar(255)
EXEC @hr = sp_OACreate 'MSWinsock.Winsock', @object OUT
EXEC @hr = sp_OASetProperty @object, 'RemoteHost', 'MyIP'
IF @hr <> 0
EXEC @hr = sp_OASetProperty @object, 'RemotePort', 1001
EXEC @hr = sp_OAMethod @object, 'Connect'
EXEC @hr = sp_OAGetProperty @object, 'State', @i OUT
WHILE @i <> 7
begin
EXEC @hr = sp_OAGetProperty @object, 'State', @i OUT
end
EXEC @hr = sp_OAMethod @object, 'SendData', NULL, 'Hola mundo'
IF @hr <> 0
BEGIN
EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT
SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
EXEC @hr = sp_OAMethod @object, 'Close'
EXEC @hr = sp_OADestroy @object
RETURN
END
EXEC @hr = sp_OAMethod @object, 'Close'
EXEC @hr = sp_OADestroy @object
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only