Microsoft KB Archive/269620

= PRB: SP_SetAppRole in RDO Causes &quot;Application Roles Can Only Be Activated at the Ad Hoc Level&quot; Error Message =

Article ID: 269620

Article Last Modified on 1/26/2001

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q269620



SYMPTOMS
When you run the sp_SetAppRole stored procedure in Remote Data Objects (RDO) to set the application role for the connection, Microsoft SQL Server returns the following error message:

40002

37000: [Microsoft][ODBC SQL Server Driver][SQL Server] Application roles can only be activated at the ad hoc level.



CAUSE
This error message occurs because a temporary stored procedure has been created to run the query.



RESOLUTION
If you use the rdExecDirect option, RDO uses the SQLExecDirect ODBC API function to run the query because no temporary stored procedure is created.

To resolve the problem, add rdExecDirect option to the Execute method call as follows: rdoConnection.Execute &quot;sp_SetAppRole 'RoleName', 'Password'&quot;, rdExecDirect

Additional query words: 40002 37000

Keywords: kbrdo kbprb KB269620

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.