Save blob via Stored Procedure

  • I have created a pdf signing method that works in asp.net and then at the end I want to update it to the datatables as a blob in tables. I my table I created a varBinary(max) field. One thing I have not gotten past is the actual storing of the file, it does not like byte but I do not know how to change to varBinary as their is no conversion in vb.net.

    Dim ms As Byte() = Convert.FromBase64String(JDSSignAjax1.SignedPDFBase64)

    For Each itm As GridDataItem In myRadGrid.Items

    sql = "Execute usp_SaveHRIssue " & itm.GetDataKeyValue("intIssuedId") & ", " & Request.QueryString("val") & ", " & GetUserId() & ", '" & ms & "'"

    insertUpdateDelete(sql)

    Next

    ALTER PROC [dbo].[usp_SaveHRIssue] (@IssuedId int, @issuedTo int, @IssuedBy int, @blob varbinary(max))

    AS

    BEGIN

    SET NOCOUNT ON;

    --Declare the variables to Use below

    Declare @RecId int;

    Select @RecId = intRecId from Drat_Issued where intIssuedId = @IssuedId;

    --Update Drat_Issued on the IssuedId for all signature that are blank

    Update Drat_Issued set blobSigned = @blob, dtSigned = getdate(), bitSigned = 1 where intIssuedId = @IssuedId;

    Insert DRAT_Transactions (intTransTypeId, intRecId, dtTransaction, intTransactionBy, intTransactionFrom)

    VALUES

    (2, @RecId, getdate(), @IssuedBy, @IssuedTo);

    --Update teh Received Record with the new inttransTypeId

    Update Drat_Received set intTransTypeID = 2 where intRecId = @RecId;

    END

  • Perhaps this will help?

    Public Shared Function StringToByteArray(ByVal hex As String) As Byte()

    Dim NumberChars As Integer = hex.Length

    Dim bytes(NumberChars / 2) As Byte

    For i As Integer = 0 To NumberChars - 1 Step 2

    bytes(i / 2) = Convert.ToByte(hex.Substring(i, 2), 16)

    Next

    Return bytes

    End Function

    from here: http://stackoverflow.com/questions/976761/dealing-with-a-varbinary-field-in-vb-net

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply