This class allows you to ensure that the current process has the required code-access security permission to access the OLE DB provider before executing code that interacts with the database. It also allows you to temporarily revoke this permission. Typically, you apply this attribute to the declaration of a method that accesses the database or to the definition of a class that contains data access code in every method. You can also apply the attribute to an assembly, struct, or constructor. The OleDbPermissionAttribute provides essentially the same functionality as the OleDbPermission class, but it allows you to add declarative security code instead of explicit (inline) code.

Note that this attribute pertains only to code access security (the policy of allowed and disallowed actions you have configured using the .NET Framework Configuration Tool). For more information, refer to the reference for the base class System.Data.Common.DBDataPermissionAttribute. Currently, there are only two additional restrictions you can impose: denying the right to use blank passwords in a connection string and restricting the allowed OLE DB drivers.

public sealed class OleDbPermissionAttribute : System.Data.Common.DBDataPermissionAttribute {

// Public Constructors

   public OleDbPermissionAttribute(System.Security.Permissions.SecurityAction action);

// Public Instance Properties

   public string Provider{set; get; } 

// Public Instance Methods public override IPermission ...

Get ADO.NET in a Nutshell now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.