OleDbConnectionStringBuilder.PersistSecurityInfo Propriedade

Definição

Obtém ou define um valor booliano que indica se informações confidenciais de segurança, como a senha, serão retornadas como parte da conexão se ela estiver aberta ou se já esteve em um estado aberto.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.

public:
 property bool PersistSecurityInfo { bool get(); void set(bool value); };
public bool PersistSecurityInfo { get; set; }
member this.PersistSecurityInfo : bool with get, set
Public Property PersistSecurityInfo As Boolean

Valor da propriedade

Boolean

O valor da propriedade PersistSecurityInfo ou false se nenhum tiver sido aplicado.The value of the PersistSecurityInfo property, or false if none has been supplied.

Exemplos

O exemplo a seguir funciona com a PersistSecurityInfo propriedade de duas maneiras.The following example works with the PersistSecurityInfo property in two ways. Primeiro, ele atribui um valor diretamente à propriedade, demonstrando o efeito que essa ação tem na cadeia de conexão resultante.First, it assigns a value directly to the property, demonstrating the effect this action has on the resulting connection string. Em seguida, o exemplo limpa o OleDbConnectionStringBuilder e atribui uma cadeia de conexão completa que contém um valor para a chave "manter informações de segurança".Then, the example clears the OleDbConnectionStringBuilder and assigns a complete connection string that contains a value for the "Persist Security Info" key. Esta etapa demonstra que definir o valor da cadeia de conexão modifica a PersistSecurityInfo propriedade também.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;
        Console.WriteLine(savedConnectionString);

        // Reset the object. This resets all the properties to their
        // default values.
        builder.Clear();

        // 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.");
        Console.ReadLine();
    }
}
Imports System.Data.OleDb    

Module Module1
  Sub Main()
    Dim builder As New OleDbConnectionStringBuilder()
    builder.PersistSecurityInfo = True
    builder.Provider = "Microsoft.Jet.Oledb.4.0"
    builder.DataSource = "C:\Sample.mdb"

    ' Store the connection string.
    Dim savedConnectionString As String = builder.ConnectionString
    Console.WriteLine(savedConnectionString)

    ' Reset the object. This resets all the properties to their
    ' default values.
    builder.Clear()

    ' 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.")
    Console.ReadLine()
  End Sub
End Module

Comentários

Essa propriedade corresponde à chave "manter informações de segurança" na cadeia de conexão.This property corresponds to the "Persist Security Info" key within the connection string.

Aplica-se a