OracleConnectionStringBuilder.Clear 方法

定义

清除 OracleConnectionStringBuilder 实例的内容。

public:
 override void Clear();
public override void Clear ();
override this.Clear : unit -> unit
Public Overrides Sub Clear ()

示例

以下示例演示了调用 Clear 方法的效果。 此示例用一些键/值对填充 OracleConnectionStringBuilder,然后调用 Clear 方法并显示结果。

// You may need to set a reference to the System.Data.OracleClient
// assembly before running this example.
using System.Data.OracleClient;

class Program
{
    static void Main()
    {
        OracleConnectionStringBuilder builder =
            new OracleConnectionStringBuilder();
        builder.DataSource = "OracleSample";
        builder.IntegratedSecurity = true;
        Console.WriteLine("Initial connection string: " +
            builder.ConnectionString);

        Console.WriteLine("Before call to Clear, count = " + builder.Count);
        builder.Clear();
        Console.WriteLine("After call to Clear, count = " + builder.Count);
        Console.WriteLine("Cleared connection string: " +
            builder.ConnectionString);
        Console.WriteLine();

        Console.WriteLine("Press Enter to continue.");
        Console.ReadLine();
    }
}
' You may need to set a reference to the System.Data.OracleClient
' assembly before running this example.
Imports System.Data.OracleClient

Module Module1
  Sub Main()
    Dim builder As New OracleConnectionStringBuilder
    builder.DataSource = "OracleSample"
    builder.IntegratedSecurity = True
    Console.WriteLine("Initial connection string: " & builder.ConnectionString)

    Console.WriteLine("Before call to Clear, count = " & builder.Count)
    builder.Clear()
    Console.WriteLine("After call to Clear, count = " & builder.Count)
    Console.WriteLine("Cleared connection string: " & builder.ConnectionString)
    Console.WriteLine()

    Console.WriteLine("Press Enter to continue.")
    Console.ReadLine()
  End Sub
End Module

注解

Clear 方法移除 OracleConnectionStringBuilder 中的所有键/值对,并重置所有对应的属性。 这包括将连接字符串重置为空字符串。

适用于

另请参阅