A
AkAlan via AccessMonster.com
I have a stored procedure that is not returning what I expect it should. I am
passing the name of a Role and it should be passing me back a 1 if the user
is a member and a 0 if not. It always returns a zero regardless of wether the
user is a member or not. I will post both the Stored procedure and the VBA
code I'm using.
VBA code:
Dim cmd As ADODB.Command
Dim prm As ADODB.Parameter
Set cmd = New ADODB.Command
Set cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = "pr_IsRoleMember"
cmd.CommandType = adCmdStoredProc
Set prm = cmd.CreateParameter("RetVal", adInteger, adParamReturnValue)
cmd.Parameters.Append prm
Set prm = cmd.CreateParameter("@RoleName", adBSTR, adParamInput, 6, "PUBLIC")
cmd.Parameters.Append prm
cmd.Execute
If cmd(0) = 1 Then
MsgBox "True"
Else
MsgBox "False"
End If
Set cmd = Nothing
Set prm = Nothing
Stored Procedure:
CREATE Procedure pr_IsRoleMember
(
@RoleName sysname
)
AS
BEGIN
DECLARE @RetVal INTEGER
IF IS_MEMBER ('@RoleName') = 1
SET @RetVal = 1
ELSE IF IS_MEMBER ('@RoleName') = 0
SET @RetVal = 0
ELSE IF IS_MEMBER ('@RoleName') IS NULL
SET @RetVal = NULL
RETURN @RetVal
END
GO
I think I'm really close just can't quite get there. Thanks for any help.
passing the name of a Role and it should be passing me back a 1 if the user
is a member and a 0 if not. It always returns a zero regardless of wether the
user is a member or not. I will post both the Stored procedure and the VBA
code I'm using.
VBA code:
Dim cmd As ADODB.Command
Dim prm As ADODB.Parameter
Set cmd = New ADODB.Command
Set cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = "pr_IsRoleMember"
cmd.CommandType = adCmdStoredProc
Set prm = cmd.CreateParameter("RetVal", adInteger, adParamReturnValue)
cmd.Parameters.Append prm
Set prm = cmd.CreateParameter("@RoleName", adBSTR, adParamInput, 6, "PUBLIC")
cmd.Parameters.Append prm
cmd.Execute
If cmd(0) = 1 Then
MsgBox "True"
Else
MsgBox "False"
End If
Set cmd = Nothing
Set prm = Nothing
Stored Procedure:
CREATE Procedure pr_IsRoleMember
(
@RoleName sysname
)
AS
BEGIN
DECLARE @RetVal INTEGER
IF IS_MEMBER ('@RoleName') = 1
SET @RetVal = 1
ELSE IF IS_MEMBER ('@RoleName') = 0
SET @RetVal = 0
ELSE IF IS_MEMBER ('@RoleName') IS NULL
SET @RetVal = NULL
RETURN @RetVal
END
GO
I think I'm really close just can't quite get there. Thanks for any help.