I am having a problem retrieving a record from a stored procedure. I am new to this, and have had success retrieving an output parameter, but now I want to retrieve an entire record.
The procedure I am trying to use is defined as...
The VB code within MS-Access looks something like...
The recordset rsReturned seems to be closed after the procedure is executed (like maybe no records are returned), but I am pretty sure with the data I feed it at run-time a record should be returned.
I would also like to know how to gain acccess to the value that is RETURNed at the end of the stored procedure (the 0 or -1 depending on @@ROWCOUNT). That might help me know that a record is being SELECTED inside the stored procedure.
The procedure I am trying to use is defined as...
Code:
ALTER PROCEDURE dbo.aspnet_Membership_GetUserByUserId
@UserId uniqueidentifier,
@CurrentTimeUtc datetime,
@UpdateLastActivity bit = 0
AS
BEGIN
IF ( @UpdateLastActivity = 1 )
BEGIN
UPDATE dbo.aspnet_Users
SET LastActivityDate = @CurrentTimeUtc
FROM dbo.aspnet_Users
WHERE @UserId = UserId
IF ( @@ROWCOUNT = 0 ) -- User ID not found
RETURN -1
END
SELECT m.Email, m.PasswordQuestion, m.Comment, m.IsApproved,
m.CreateDate, m.LastLoginDate, u.LastActivityDate,
m.LastPasswordChangedDate, u.UserName, m.IsLockedOut,
m.LastLockoutDate
FROM dbo.aspnet_Users u, dbo.aspnet_Membership m
WHERE @UserId = u.UserId AND u.UserId = m.UserId
IF ( @@ROWCOUNT = 0 ) -- User ID not found
RETURN -1
RETURN 0
END
The VB code within MS-Access looks something like...
Code:
Dim adoCmd As New ADODB.Command
Dim rsReturned As New ADODB.Recordset
With adoCmd
.ActiveConnection = CurrentProject.Connection
.CommandText = "aspnet_Membership_GetUserByUserId"
.CommandType = adCmdStoredProc
.Parameters.Append .CreateParameter("@UserID", adGUID, adParamInput, , Me.aspnet_UserID)
.Parameters.Append .CreateParameter("@CurrentTimeUtc", adDate, adParamInput, , Now())
.Parameters.Append .CreateParameter("@UpdateLastActivity", adBoolean, adParamInput, , 1)
Set rsReturned = .Execute
End With
The recordset rsReturned seems to be closed after the procedure is executed (like maybe no records are returned), but I am pretty sure with the data I feed it at run-time a record should be returned.
I would also like to know how to gain acccess to the value that is RETURNed at the end of the stored procedure (the 0 or -1 depending on @@ROWCOUNT). That might help me know that a record is being SELECTED inside the stored procedure.