ACC2002: Error Message: Application Roles Can Only Be Activated at the Ad Hoc Level (310824)



The information in this article applies to:

  • Microsoft Access 2002

This article was previously published under Q310824
Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies only to a Microsoft Access project (.adp).

SYMPTOMS

When you try to execute the Microsoft SQL Server stored procedure sp_setapprole from a Microsoft Access project (ADP), you receive the following error message:
Application roles can only be activated at the ad hoc level.

CAUSE

You are executing the sp_setapprole stored procedure within the context of another stored procedure. By design, sp_setapprole cannot be executed if it is nested within another stored procedure.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Open the sample Access project NorthwindCS.adp, and connect it to Microsoft SQL Server 2000.
  2. In the Database window, click Queries under Objects, click New, click Create Text Stored Procedure, and then click OK to create a new stored procedure.
  3. Replace the existing stored procedure text with the following text:
    CREATE PROCEDURE spMyProcedure
    AS
    EXEC sp_setapprole 'AppRoleName' ,'Password'
    					
  4. Save and run the stored procedure spMyProcedure. Note that you receive the error message that is mentioned in the "Symptoms" section of this article.

Modification Type:MajorLast Reviewed:9/25/2003
Keywords:kberrmsg kbprb KB310824