SqlCommand.Connection プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > SqlCommand.Connection プロパティの意味・解説 

SqlCommand.Connection プロパティ

この SqlCommand のインスタンス使用する SqlConnection を取得または設定します

名前空間: System.Data.SqlClient
アセンブリ: System.Data (system.data.dll 内)
構文構文

Dim instance As SqlCommand
Dim value As SqlConnection

value = instance.Connection

instance.Connection = value
public SqlConnection Connection { get; set;
 }
public:
property SqlConnection^ Connection {
    SqlConnection^ get ();
    void set (SqlConnection^ value);
}
/** @property */
public SqlConnection get_Connection ()

/** @property */
public void set_Connection (SqlConnection value)

プロパティ
データ ソースへの接続既定値null 参照 (Visual Basic では Nothing) です。

例外例外
解説解説
使用例使用例

SqlCommand作成し、そのプロパティ一部設定する例を次に示します

Public Sub CreateCommand(ByVal
 queryString As String, _
  ByVal connectionString As String)
    Using connection As New SqlConnection(connectionString)
        Dim command As New
 SqlCommand()
        command.Connection = connection
        command.CommandTimeout = 15
        command.CommandType = CommandType.Text
        command.CommandText = queryString

        connection.Open()
        Dim reader As SqlDataReader = command.ExecuteReader()
            While reader.Read()
            Console.WriteLine(String.Format("{0},
 {1}", _
                reader(0), reader(1)))
        End While
    End Using
End Sub
private static void CreateCommand(string
 queryString,
    string connectionString)
{
    using (SqlConnection connection = new SqlConnection(
               connectionString))
    {
        SqlCommand command = new SqlCommand();
        command.Connection = connection;
        command.CommandTimeout = 15;
        command.CommandType = CommandType.Text;
        command.CommandText = queryString;

        connection.Open();
        SqlDataReader reader = command.ExecuteReader();
        while (reader.Read())
        {
            Console.WriteLine(String.Format("{0}, {1}",
                reader[0], reader[1]));
        }
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SqlCommand クラス
SqlCommand メンバ
System.Data.SqlClient 名前空間
SqlCommand.CommandText プロパティ
SqlCommand.CommandTimeout プロパティ
SqlCommand.CommandType プロパティ


このページでは「.NET Framework クラス ライブラリ リファレンス」からSqlCommand.Connection プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からSqlCommand.Connection プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からSqlCommand.Connection プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「SqlCommand.Connection プロパティ」の関連用語

SqlCommand.Connection プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



SqlCommand.Connection プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS