Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Acess Project Stored Procedure 1

Status
Not open for further replies.

eletuw

Programmer
Sep 15, 2000
15
GB
I have a stored procedure on SQL Server called by Access project. The stored procedure return either 0 or 1 if a login is a member of as server role.
How do I receive the returned value in Access module.
I am using the following to run the stored procedure:

CurrentProject.Connection.Execute "checkrole"

Thanks for your help.
 
You can use a Command object to execute the stored procedure and retrieve the result. For example:
Code:
Dim com As ADODB.Command
Dim lRet As Long

Set com = New ADODB.Command
With com
  .ActiveConnection = CurrentProject.Connection
  .CommandText = "dbo.sp_CheckServerRole"
  .CommandTimeout = 0
  .CommandType = adCmdStoredProc
  .Parameters.Refresh
  .Parameters("@UserID") = Me!UserID
  .Parameters("@ServerRole") = "dbcreator"  'Can add DB
  .Execute
  While .State = adStateExecuting
    DoEvents
  Wend
  lRet = .Parameters(0)
End With
Set com = Nothing

If lRet = 1 Then 'Member of Server role
  '
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top