Sample code for 30+ languages & platforms
SQL Server

Example: Crypt2.GetSignatureSigningTimeStr method

Demonstrates how to call the GetSignatureSigningTimeStr method.

Chilkat SQL Server Downloads

SQL Server
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @success int
    SELECT @success = 0

    DECLARE @crypt int
    EXEC @hr = sp_OACreate 'Chilkat.Crypt2', @crypt OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    EXEC sp_OAMethod @crypt, 'VerifyP7M', @success OUT, 'qa_data/cades/CAdES-T/Signature-C-T-1.p7m', 'qa_output/out.dat'
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @crypt, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @crypt
        RETURN
      END

    DECLARE @numSigners int
    EXEC sp_OAGetProperty @crypt, 'NumSignerCerts', @numSigners OUT

    PRINT 'Num Signers = ' + @numSigners

    DECLARE @i int
    SELECT @i = 0
    WHILE @i < @numSigners
      BEGIN
        EXEC sp_OAMethod @crypt, 'HasSignatureSigningTime', @iTmp0 OUT, @i
        IF @iTmp0 = 1
          BEGIN

            EXEC sp_OAMethod @crypt, 'GetSignatureSigningTimeStr', @sTmp0 OUT, @i
            PRINT @i + 1 + ': ' + @sTmp0
          END
        ELSE
          BEGIN

            PRINT @i + 1 + ': has no signing time.'
          END
        SELECT @i = @i + 1
      END

    -- Sample output:

    -- Num Signers = 1
    -- 1: Sun, 03 Dec 2013 06:57:41 GMT

    EXEC @hr = sp_OADestroy @crypt


END
GO