(SQL Server) Example: Crypt2.CrcBd method
Demonstrates how to call the CrcBd method.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @crypt int
EXEC @hr = sp_OACreate 'Chilkat.Crypt2', @crypt OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @bd int
EXEC @hr = sp_OACreate 'Chilkat.BinData', @bd OUT
DECLARE @success int
EXEC sp_OAMethod @bd, 'AppendString', @success OUT, '123456789', 'us-ascii'
DECLARE @crc32 int
EXEC sp_OAMethod @crypt, 'CrcBd', @crc32 OUT, 'crc-32', @bd
-- The decimal value is 3421780262 (converted to hex is 0xCBF43926)
PRINT @crc32
DECLARE @crc8 int
EXEC sp_OAMethod @crypt, 'CrcBd', @crc8 OUT, 'crc8', @bd
PRINT @crc8
EXEC @hr = sp_OADestroy @crypt
EXEC @hr = sp_OADestroy @bd
END
GO
|