OleDbConnectionStringBuilder.PersistSecurityInfo 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置一个布尔值,该值指示如果连接是打开的或者一直处于打开状态,那么安全敏感信息(如密码)是否作为连接的一部分返回。
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
属性值
为 PersistSecurityInfo 属性的值,或者,如果未提供任何值,则为 false
。
示例
以下示例通过两种方式使用 PersistSecurityInfo 属性。 首先,它直接向 属性赋值,演示此操作对生成的连接字符串的影响。 然后,该示例清除 OleDbConnectionStringBuilder 并分配包含“持久化安全信息”键值的完整连接字符串。 此步骤演示从 连接字符串设置 值也会PersistSecurityInfo修改 属性。
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
注解
此属性对应于连接字符串中的“持久化安全信息”键。