SQL Server
SQL Server
Active and Passive Modes in FTP
See more FTP Examples
The Passive property controls whether data connections for uploads/downloads are established in Active or Passive mode. To use Active mode, set the Passive property = _FALSE_. This is the default. To use Passive mode, set the Passive property = _TRUE_.
About Passive/Active Modes:
Active Mode:
The FTP client chooses a port number and sends a “PORT” command to the FTP server. The FTP client then listens at the chosen port and the FTP server issues a connect request to establish the connection. The data connection is outgoing from the FTP server, and incoming to the FTP client.
Passive Mode:
The FTP client sends a PASV command to the FTP server. The FTP server chooses a port number and sends it in the PASV response. The FTP server then listens at that port for the incoming connect request from the FTP client. The data connection is incoming to the FTP server, and outgoing from the FTP client.
Chilkat SQL Server Downloads
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @ftp int
EXEC @hr = sp_OACreate 'Chilkat.Ftp2', @ftp OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
EXEC sp_OASetProperty @ftp, 'Hostname', 'ftp.something.com'
EXEC sp_OASetProperty @ftp, 'Username', 'test'
EXEC sp_OASetProperty @ftp, 'Password', 'test'
-- Connect and login to the FTP server.
EXEC sp_OAMethod @ftp, 'Connect', @success OUT
IF @success <> 1
BEGIN
EXEC sp_OAGetProperty @ftp, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @ftp
RETURN
END
-- To use Passive mode:
EXEC sp_OASetProperty @ftp, 'Passive', 1
-- or...
-- To use Active mode:
EXEC sp_OASetProperty @ftp, 'Passive', 0
-- ..
EXEC @hr = sp_OADestroy @ftp
END
GO