(SQL Server) Example to Download Web Page as MHT Archive
Demonstrates how to download a web page into a .mht web archive.
-- 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)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @mht int
-- Use "Chilkat_9_5_0.Mht" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Mht', @mht OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
EXEC sp_OAMethod @mht, 'GetAndSaveMHT', @success OUT, 'http://www.piscatur.com/', 'qa_data/mht/piscatur.mht'
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @mht, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @mht
RETURN
END
ELSE
BEGIN
PRINT 'MHT Created!'
END
EXEC @hr = sp_OADestroy @mht
END
GO
|