Information générale
Forum:
Microsoft SQL Server
Catégorie:
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
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement