OleDbConnection.ConnectionTimeout プロパティ
アセンブリ: System.Data (system.data.dll 内)

接続が開かれるまでの待機時間 (秒)。既定値は 15 秒です。



OleDbConnection を作成し、そのプロパティの一部を接続文字列に設定する例を次に示します。
' The connectionString argument contains the Connect Timeout ' keywords, as follows: "... ;Connect Timeout=30;" Public Sub InsertRow(ByVal connectionString As String, _ ByVal insertSQL As String) Using connection As New OleDbConnection(connectionString) ' The insertSQL string contains a SQL statement that ' inserts a new row in the source table. Dim command As New OleDbCommand(insertSQL) ' Set the Connection to the new OleDbConnection. command.Connection = connection ' Open the connection and execute the insert command. Try connection.Open() command.ExecuteNonQuery() Catch ex As Exception Console.WriteLine(ex.Message) End Try ' The connection is automatically closed when the ' code exits the Using block. End Using End Sub
// The connectionString argument contains the Connect Timeout // keywords, as follows: "... ;Connect Timeout=30;" public void InsertRow(string connectionString, string insertSQL) { using (OleDbConnection connection = new OleDbConnection(connectionString)) { // The insertSQL string contains a SQL statement that // inserts a new row in the source table. OleDbCommand command = new OleDbCommand(insertSQL); // Set the Connection to the new OleDbConnection. command.Connection = connection; // Open the connection and execute the insert command. try { connection.Open(); command.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.Message); } // The connection is automatically closed when the // code exits the using block. }
using System; using System.Data; using System.Data.OleDb; class Class1 { static void Main() { } // The connectionString argument contains the Connect Timeout // keywords, as follows: "... ;Connect Timeout=30;" public void InsertRow(string connectionString, string insertSQL) { using (OleDbConnection connection = new OleDbConnection(connectionString)) { // The insertSQL string contains a SQL statement that // inserts a new row in the source table. OleDbCommand command = new OleDbCommand(insertSQL); // Set the Connection to the new OleDbConnection. command.Connection = connection; // Open the connection and execute the insert command. try { connection.Open(); command.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.Message); } // The connection is automatically closed when the // code exits the using block. }

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- OleDbConnection.ConnectionTimeout プロパティのページへのリンク