SQL Server
SQL Server
Zip Append Files Verbose Logging
See more Zip Examples
An application can check verbose LastErrorText if the zip.AppendFiles method does not append the expected files, or if it appends nothing.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 @zip int
EXEC @hr = sp_OACreate 'Chilkat.Zip', @zip OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
EXEC sp_OAMethod @zip, 'NewZip', @success OUT, 'qa_output/test1.zip'
-- Turn on verbose logging to get more informaiton in the LastErrorText property.
EXEC sp_OASetProperty @zip, 'VerboseLogging', 1
DECLARE @recurse int
SELECT @recurse = 1
EXEC sp_OASetProperty @zip, 'AppendFromDir', 'qa_data/syncTree'
EXEC sp_OAMethod @zip, 'AppendFiles', @success OUT, '*', @recurse
-- Even if AppendFiles is successful, we can examine the LastErrorText property
-- to see what happend. (This is true for all Chilkat methods. The LastErrorText always
-- contains information even when the method call is successful. If you have a difficult
-- time understanding what happened, then turn on VerboseLogging and have a look at it.
-- Make sure to turn off VerboseLogging for production because it could slow down your application.)
EXEC sp_OAGetProperty @zip, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
-- Here is a sample of the LastErrorText for this test:
-- ChilkatLog:
-- AppendFiles(62ms):
-- DllDate: Feb 10 2019
-- ChilkatVersion: 9.5.0.76
-- UnlockPrefix: ***
-- Architecture: Little Endian; 64-bit
-- Language: .NET 4.5 / x64 / VS2012
-- VerboseLogging: 1
-- Component successfully unlocked using purchased unlock code.
-- appendFileEx(62ms):
-- FilePattern: *
-- AppendFromDir: qa_data/syncTree
-- PathPrefix:
-- BaseDir: c:\appData\UnitTest\qa_data\syncTree\
-- InzipBase:
-- FilenamePart: *
-- IsSpecificFile: 0
-- recurse: 1
-- saveExtraPath: 0
-- archiveOnly: 0
-- includeHidden: 1
-- includeSystem: 1
-- ignoreAccessDenied: 1
-- addFilesMax:
-- addDirNonRecursive:
-- ffWin32OpenDir_fileSpec: [c:\appData\UnitTest\qa_data\syncTree\*]
-- ffWin32OpenDir_fileSpec: [c:\appData\UnitTest\qa_data\syncTree\abc\*]
-- ffWin32OpenDir_fileSpec: [c:\appData\UnitTest\qa_data\syncTree\data\*]
-- ffWin32OpenDir_fileSpec: [c:\appData\UnitTest\qa_data\syncTree\text\*]
-- ffWin32OpenDir_fileSpec: [c:\appData\UnitTest\qa_data\syncTree\abc\ghk\*]
-- ffWin32OpenDir_fileSpec: [c:\appData\UnitTest\qa_data\syncTree\data\xyz\*]
-- ffWin32OpenDir_fileSpec: [c:\appData\UnitTest\qa_data\syncTree\text\something\*]
-- --addDirNonRecursive
-- --addFilesMax
-- No exclusion patterns.
-- numAdded: 20
-- --appendFileEx
-- Success.
-- --AppendFiles
-- --ChilkatLog
EXEC sp_OAMethod @zip, 'WriteZipAndClose', @success OUT
IF @success <> 1
BEGIN
EXEC sp_OAGetProperty @zip, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @zip
RETURN
END
EXEC @hr = sp_OADestroy @zip
END
GO