Thanks Michael,
Please let me clarify what I'm trying to do, and maybe you can help me
with the code?
On the SQL Server, I have the following UDF:
CREATE FUNCTION rc4_fnEncryption
(@p_cKey varchar(255),@p_cData varchar(255)) RETURNS varchar(255)
It accepts a key and a string, runs it through an encryption routine,
and returns it.
I would like to run this UDF from a VBA module within Access (where
the key will be stored. We are using ADO, so that means no pass-thru
queries (right?)
------------------------------------------------------------------------------------
I've created a Stored Procedure to call the function (and it works):
CREATE PROCEDURE dbo.sp_EnDeCrypt(@chrWD char(12), @chrSTRING
varchar(255), @cResult varchar(255) OUTPUT) AS
SET @cResult = dbo.rc4_fnEncryption(@chrWD,@chrString)
GO
---------------------------------------------------------------------------------
I can successfully call the Stored Procedure from within the Access
Module with code:
Const connectionString As String = "Driver=SQL Server;
Server=MYServer;Database=MYDatabase;Trusted_Connection=Yes"
Dim cnn As ADODB.Connection
Dim cmd As ADODB.Command
Dim prm As ADODB.Parameter
Set cnn = New ADODB.Connection
cnn.Open connectionString
Set cmd = New ADODB.Command
cmd.ActiveConnection = cnn
cmd.CommandText = "sp_EnDeCrypt"
cmd.CommandType = adCmdStoredProc
Set prm = cmd.CreateParameter("chrWD", adWChar, adParamInput, 12,
"cnst_UO_ORSA")
cmd.Parameters.Append prm
Set prm = cmd.CreateParameter("chrString", adWChar, adParamInput, 255,
strString)
cmd.Parameters.Append prm
Set prm = cmd.CreateParameter("cResult", adWChar, adParamOutput, 255)
cmd.Parameters.Append prm
cmd.Execute
MsgBox cmd.Parameters("cResult")
Set prm = Nothing
Set cmd = Nothing
Set cnn = Nothing
End Function
-----------------------------------------------------------------------------------------------------------------
Do you know how to write the code that will execute the UDF and return
a value?
thank you,
Steve Shapiro
University of Oregon