OleDbConnectionStringBuilder.PersistSecurityInfo Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets a Boolean value that indicates whether security-sensitive information, such as the password, is returned as part of the connection if the connection is open or has ever been in an open state.

Namespace: System.Data.OleDb
Assembly: System.Data (in system.data.dll)

public bool PersistSecurityInfo { get; set; 
/** @property */
public boolean get_PersistSecurityInfo ()

/** @property */
public void set_PersistSecurityInfo (boolean value)

public function get PersistSecurityInfo () : boolean

public function set PersistSecurityInfo (value : boolean)

Property Value

The value of the PersistSecurityInfo property, or false if none has been supplied.

This property corresponds to the "Persist Security Info" key within the connection string.

The following example works with the PersistSecurityInfo property in two ways. First, it assigns a value directly to the property, demonstrating the effect this action has on the resulting connection string. Then, the example clears the OleDbConnectionStringBuilder and assigns a complete connection string that contains a value for the "Persist Security Info" key. This step demonstrates that setting the value from the connection string modifies the PersistSecurityInfo property, as well.

using System.Data.OleDb;

class Program
    static void Main()
        OleDbConnectionStringBuilder builder =
            new OleDbConnectionStringBuilder();
        builder.PersistSecurityInfo = true;
        builder.Provider = "Microsoft.Jet.Oledb.4.0";
        builder.DataSource = @"C:\Sample.mdb";

        // Store the connection string.
        string savedConnectionString = builder.ConnectionString;

        // Reset the object. This resets all the properties to their
        // default values.

        // Investigate the PersistSecurityInfo property before
        // and after assigning a connection string value.
        Console.WriteLine("Default : " + builder.PersistSecurityInfo);
        builder.ConnectionString = savedConnectionString;
        Console.WriteLine("Modified: " + builder.PersistSecurityInfo);

        Console.WriteLine("Press Enter to finish.");

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions