DbConnectionStringBuilder.Values 属性
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个包含 ICollection 中的值的 DbConnectionStringBuilder。
public:
virtual property System::Collections::ICollection ^ Values { System::Collections::ICollection ^ get(); };
public virtual System.Collections.ICollection Values { get; }
[System.ComponentModel.Browsable(false)]
public virtual System.Collections.ICollection Values { get; }
member this.Values : System.Collections.ICollection
[<System.ComponentModel.Browsable(false)>]
member this.Values : System.Collections.ICollection
Public Overridable ReadOnly Property Values As ICollection
一个 ICollection,包含 DbConnectionStringBuilder 中的值。
- 属性
备注
该示例包括一个密码以演示 DbConnectionStringBuilder 如何使用连接字符串。 在您的应用程序中,建议使用 Windows 身份验证。 如果必须使用密码,请不要在你的应用程序中包括硬编码的密码。
static void Main()
{
DbConnectionStringBuilder builder = new DbConnectionStringBuilder();
builder.ConnectionString =
"Provider=MSDataShape.1;Persist Security Info=false;" +
"Data Provider=MSDAORA;Data Source=orac;" +
"user id=username;password=*******";
foreach (string value in builder.Values)
Console.WriteLine(value);
}
Sub Main()
Dim builder As New DbConnectionStringBuilder
builder.ConnectionString = _
"Provider=MSDataShape.1;Persist Security Info=False;" & _
"Data Provider=MSDAORA;Data Source=orac;" & _
"user id=username;password=*******"
For Each value As String In builder.Values
Console.WriteLine(value)
Next
End Sub
显示以下输出:
MSDataShape.1
false
MSDAORA
orac
username
*******
中ICollection值的顺序未指定,但它与 方法返回Keys的 中ICollection关联的键的顺序相同。
返回的 ICollection 不是静态副本;相反, ICollection 引用回原始 DbConnectionStringBuilder中的值。 因此,对 DbConnectionStringBuilder 的更改将反映在 中 ICollection。
产品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
UWP | 10.0 |