SqlParameterCollection クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
SqlCommand に関連付けられたパラメーターと、DataSet 内の列に対するそれぞれのマッピング コレクションを表します。 このクラスは継承できません。
public ref class SqlParameterCollection sealed : System::Data::Common::DbParameterCollection
public ref class SqlParameterCollection sealed : MarshalByRefObject, System::Collections::IList, System::Data::IDataParameterCollection
public ref class SqlParameterCollection sealed : System::Data::Common::DbParameterCollection, System::Collections::IList
public sealed class SqlParameterCollection : System.Data.Common.DbParameterCollection
[System.ComponentModel.ListBindable(false)]
public sealed class SqlParameterCollection : MarshalByRefObject, System.Collections.IList, System.Data.IDataParameterCollection
[System.ComponentModel.ListBindable(false)]
public sealed class SqlParameterCollection : System.Data.Common.DbParameterCollection
[System.ComponentModel.ListBindable(false)]
public sealed class SqlParameterCollection : System.Data.Common.DbParameterCollection, System.Collections.IList
type SqlParameterCollection = class
inherit DbParameterCollection
[<System.ComponentModel.ListBindable(false)>]
type SqlParameterCollection = class
inherit MarshalByRefObject
interface IDataParameterCollection
interface IList
interface ICollection
interface IEnumerable
[<System.ComponentModel.ListBindable(false)>]
type SqlParameterCollection = class
inherit DbParameterCollection
[<System.ComponentModel.ListBindable(false)>]
type SqlParameterCollection = class
inherit DbParameterCollection
interface IDataParameterCollection
interface IList
interface ICollection
interface IEnumerable
Public NotInheritable Class SqlParameterCollection
Inherits DbParameterCollection
Public NotInheritable Class SqlParameterCollection
Inherits MarshalByRefObject
Implements IDataParameterCollection, IList
Public NotInheritable Class SqlParameterCollection
Inherits DbParameterCollection
Implements IList
- 継承
- 継承
- 継承
- 属性
- 実装
例
次の例では、コレクションを介して複数の SqlParameter インスタンスを SqlParameterCollection 作成します。 パラメーターを使用して、データ ソース内のデータを選択し、 DataSet. このコードでは、適切な DataSet スキーマ、コマンド、接続を SqlDataAdapter 使用して a と a が既に作成されていることを前提としています。
public void AddSqlParameters()
{
// ...
// create categoriesDataSet and categoriesAdapter
// ...
categoriesAdapter.SelectCommand.Parameters.Add(
"@CategoryName", SqlDbType.VarChar, 80).Value = "toasters";
categoriesAdapter.SelectCommand.Parameters.Add(
"@SerialNum", SqlDbType.Int).Value = 239;
categoriesAdapter.Fill(categoriesDataSet);
}
Public Sub AddSqlParameters()
' ...
' create categoriesDataSet and categoriesAdapter
' ...
categoriesAdapter.SelectCommand.Parameters.Add( _
"@CategoryName", SqlDbType.VarChar, 80).Value = "toasters"
categoriesAdapter.SelectCommand.Parameters.Add( _
"@SerialNum", SqlDbType.Int).Value = 239
categoriesAdapter.Fill(categoriesDataSet)
End Sub
注釈
ストアド プロシージャ名とは対照的に、コマンドにアドホック SQL ステートメントが含まれている場合、コレクション内のパラメーターの数は、コマンド テキスト内のパラメーター プレースホルダーの数と等しいか、エラーが発生SQL Server必要があります。 ストアド プロシージャでは、既定値なしでストアド プロシージャで宣言されているすべてのパラメーターを指定する必要があります。 既定値で宣言されたパラメーターは省略可能です。 これにより、既定値以外の値を指定できます。
パラメーターの使用方法を示す追加のサンプル コードの詳細については、「 コマンドとパラメーター」を参照してください。
プロパティ
| Count |
SqlParameterCollection の要素数を格納している整数を返します。 読み取り専用です。 |
| IsFixedSize |
SqlParameterCollection が固定サイズかどうかを示す値を取得します。 |
| IsFixedSize |
コレクションが固定サイズかどうかを指定します。 (継承元 DbParameterCollection) |
| IsReadOnly |
SqlParameterCollection が読み取り専用かどうかを示す値を取得します。 |
| IsReadOnly |
コレクションが読み取り専用かどうかを指定します。 (継承元 DbParameterCollection) |
| IsSynchronized |
SqlParameterCollection が同期されているかどうかを示す値を取得します。 |
| IsSynchronized |
コレクションが同期されているかどうかを指定します。 (継承元 DbParameterCollection) |
| Item[Int32] |
指定されたインデックス位置にある SqlParameter を取得します。 |
| Item[String] |
指定された名前を持つ SqlParameter を取得します。 |
| SyncRoot |
SqlParameterCollection へのアクセスを同期するために使用できるオブジェクトを取得します。 |
メソッド
明示的なインターフェイスの実装
| ICollection.IsSynchronized |
ICollection へのアクセスが同期されている (スレッド セーフである) かどうかを示す値を取得します。 (継承元 DbParameterCollection) |
| IDataParameterCollection.Item[String] |
指定したインデックスにあるパラメーターを取得または設定します。 (継承元 DbParameterCollection) |
| IList.IsFixedSize |
IList が固定サイズかどうかを示す値を取得します。 (継承元 DbParameterCollection) |
| IList.IsReadOnly |
IList が読み取り専用かどうかを示す値を取得します。 (継承元 DbParameterCollection) |
| IList.Item[Int32] |
指定したインデックスにある要素を取得または設定します。 (継承元 DbParameterCollection) |
拡張メソッド
| Cast<TResult>(IEnumerable) |
IEnumerable の要素を、指定した型にキャストします。 |
| OfType<TResult>(IEnumerable) |
指定された型に基づいて IEnumerable の要素をフィルター処理します。 |
| AsParallel(IEnumerable) |
クエリの並列化を有効にします。 |
| AsQueryable(IEnumerable) |
IEnumerable を IQueryable に変換します。 |