使用英语阅读

通过


DbConnectionStringBuilder.Values 属性

定义

获取一个包含 ICollection 中的值的 DbConnectionStringBuilder

public virtual System.Collections.ICollection Values { get; }
[System.ComponentModel.Browsable(false)]
public virtual System.Collections.ICollection Values { get; }

属性值

一个 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);
}

显示以下输出:

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

另请参阅