SQL Server
SQL Server
FTP Automatic Post-Connect Commands
See more FTP Examples
Demonstrates the AutoFeat, AutoSyst, AutoOptsUtf8, and AutoXcrc properties, which control commands Chilkat issues automatically around connecting and transferring.
Background: Chilkat normally probes and adapts to a server on its own:
AutoFeat discovers capabilities with FEAT, AutoSyst learns the OS type to parse legacy listings, and AutoOptsUtf8 enables UTF-8 filenames when the server advertises it. These are on by default and rarely worth changing. AutoXcrc is the exception worth enabling deliberately — it verifies each upload with the server's XCRC checksum, catching corruption automatically where supported.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
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.example.com'
EXEC sp_OASetProperty @ftp, 'Username', 'myFtpLogin'
-- These auto-* properties control commands Chilkat sends automatically after connecting. They
-- are on/off by default as noted, and are rarely changed.
-- AutoFeat (default 1): automatically send FEAT to discover server capabilities.
EXEC sp_OASetProperty @ftp, 'AutoFeat', 1
-- AutoSyst (default 1): automatically send SYST after login to learn the server OS type.
EXEC sp_OASetProperty @ftp, 'AutoSyst', 1
-- AutoOptsUtf8 (default 1): send OPTS UTF8 ON when the FEAT response advertises UTF8.
EXEC sp_OASetProperty @ftp, 'AutoOptsUtf8', 1
-- AutoXcrc (default 0): request an XCRC checksum after each upload and treat a mismatch as
-- a failure, giving automatic post-upload verification where the server supports XCRC.
EXEC sp_OASetProperty @ftp, 'AutoXcrc', 1
-- Normally you would not hard-code the password in source. You should instead obtain it
-- from an interactive prompt, environment variable, or a secrets vault.
EXEC sp_OASetProperty @ftp, 'Password', 'myPassword'
EXEC sp_OAMethod @ftp, 'Connect', @success OUT
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @ftp, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @ftp
RETURN
END
PRINT 'Connected with the configured automatic features.'
EXEC sp_OAMethod @ftp, 'Disconnect', @success OUT
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @ftp, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @ftp
RETURN
END
EXEC @hr = sp_OADestroy @ftp
END
GO