March 15, 2006 at 7:53 am
I'm trying to access a method within a VB dll using sp_OAMethod. Here's the VB method:
Public Function Encrypt(ByVal Account As String) As String
Dim cryptor As Object
Set cryptor = CreateObject("Activecrypt.RSACrypt")
cryptor.Async = False
PublicKeyString = cryptor.LoadKey("publickey_file.pem", "")
Encrypt = cryptor.PublicEncrypt(PublicKeyString, Account_No)
Set cryptor = Nothing
End Function
-----------------------------
This is used to encrypt a string - it returns another string with a length of 175 characters. Here's my TSQL call to it:
DECLARE @retVal INT
DECLARE @comHandle INT
DECLARE @errorSource VARCHAR(8000)
DECLARE @errorDescription VARCHAR(8000)
DECLARE @retString VARCHAR(500)
EXEC @retVal = sp_OAMethod @comHandle, 'Encrypt', @retString OUTPUT, '4890398732'
select @retVal as Method_Return
IF (@retVal <> 0)
BEGIN
-- Trap errors if any
EXEC sp_OAGetErrorInfo @comHandle, @errorSource OUTPUT, @errorDescription OUTPUT
SELECT [Error Source] = @errorSource, [Description] = @errorDescription
RETURN
END
SELECT @retString as 'Converted Str'
--------------------------------------------
Now when I run this (I succesfuly instantiate the object), what is returned is an empty string. I have another VB method within the same dll that creates a hash value of a string, and this works fine. Any ideas as to what is amiss?
March 15, 2006 at 9:03 am
Eric,
Whenever I have used sp_OAMethod I have only used 2 parameters - see below where I save and close an Excel spreadsheet...
Steve
******************************
--save and close Excel workbook
EXECUTE @hr = sp_OAMethod @workbook, 'SaveAs("c:\steve.xls")'
EXECUTE @hr = sp_OAMethod @workbook, 'Close'
March 15, 2006 at 9:52 am
How/why would I only use 2 parameters?
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply