Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Winsock control
Message
De
21/09/2004 19:56:22
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Titre:
Winsock control
Divers
Thread ID:
00944803
Message ID:
00944803
Vues:
133
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
Répondre
Fil
Voir

Click here to load this message in the networking platform