OleDbConnectionStringBuilder.Clear メソッド
アセンブリ: System.Data (system.data.dll 内)


Clear メソッドは、OleDbConnectionStringBuilder からすべてのキー/値ペアを削除し、対応するすべてのプロパティを既定値にリセットします。たとえば、Count プロパティは 0 に、ConnectionString プロパティは空の文字列に設定されます。

Clear メソッドを呼び出す例を次に示します。この例では、OleDbConnectionStringBuilder に、いくつかのキー/値ペアを格納した後、Clear メソッドを呼び出して、その結果を表示します。
![]() |
---|
この例には、OleDbConnectionStringBuilder と接続文字列がどのように連携するかを示すパスワードが含まれています。アプリケーションでは、Windows 認証の使用をお勧めします。パスワードを使用する必要がある場合は、ハードコーディングされたパスワードをアプリケーションに組み込まないでください。 |
Imports System.Data.OleDb Module Module1 Sub Main() Dim builder As New OleDbConnectionStringBuilder() builder.ConnectionString = "Data Source=C:\Sample.mdb" ' Call the Add method to explicitly add key/value ' pairs to the internal collection. builder.Add("Provider", "Microsoft.Jet.Oledb.4.0") builder.Add("Jet OLEDB:Database Password", "MyPassword!") builder.Add("Jet OLEDB:System Database", "C:\Workgroup.mdb") ' Set up row-level locking. builder.Add("Jet OLEDB:Database Locking Mode", 1) ' Dump the contents of the "filled-in" OleDbConnectionStringBuilder ' to the console window. DumpBuilderContents(builder) ' Clear current values and reset known keywords to their ' default values. builder.Clear() ' Dump the contents of the newly emptied ' OleDbConnectionStringBuilder ' to the console window. DumpBuilderContents(builder) Console.WriteLine("Press Enter to continue.") Console.ReadLine() End Sub Private Sub DumpBuilderContents(ByVal builder As OleDbConnectionStringBuilder) Console.WriteLine("=================") Console.WriteLine("builder.ConnectionString = " & builder.ConnectionString) For Each key As String In builder.Keys Console.WriteLine(key & "=" & builder.Item(key).ToString) Next End Sub End Module
using System.Data.OleDb; class Program { static void Main() { OleDbConnectionStringBuilder builder = new OleDbConnectionStringBuilder(); builder.ConnectionString = @"Data Source=c:\Sample.mdb"; // Call the Add method to explicitly add key/value // pairs to the internal collection. builder.Add("Provider", "Microsoft.Jet.Oledb.4.0"); builder.Add("Jet OLEDB:Database Password", "MyPassword!"); builder.Add("Jet OLEDB:System Database", @"C:\Workgroup.mdb"); // set up row-level locking. builder.Add("Jet OLEDB:Database Locking Mode", 1); // Dump the contents of the "filled-in" // OleDbConnectionStringBuilder // to the console window. DumpBuilderContents(builder); // Clear current values and reset known keys to their // default values. builder.Clear(); // Dump the contents of the newly emptied // OleDbConnectionStringBuilder // to the console window. DumpBuilderContents(builder); Console.WriteLine("Press Enter to continue."); Console.ReadLine(); } private static void DumpBuilderContents(OleDbConnectionStringBuilder builder) { Console.WriteLine("================="); Console.WriteLine("builder.ConnectionString = " + builder.ConnectionString); foreach (string key in builder.Keys) { Console.WriteLine(key + "=" + builder[key].ToString()); } } }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からOleDbConnectionStringBuilder.Clear メソッドを検索する場合は、下記のリンクをクリックしてください。

- OleDbConnectionStringBuilder.Clear メソッドのページへのリンク