Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Winsock control
Message
From
21/09/2004 19:56:22
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Title:
Winsock control
Miscellaneous
Thread ID:
00944803
Message ID:
00944803
Views:
132
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
Map
View

Click here to load this message in the networking platform