共用方式為


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 移除所有的索引鍵/值組,並重設所有對應的屬性。 這包括將 連接字串 重設為空字串。

適用於

另請參閱