OleDbParameterCollection クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
OleDbCommandに関連するパラメーターのコレクションと、DataSet内の列へのそれぞれのマッピングを表します。
public ref class OleDbParameterCollection sealed : MarshalByRefObject, System::Collections::IList, System::Data::IDataParameterCollection
public ref class OleDbParameterCollection sealed : System::Data::Common::DbParameterCollection
[System.ComponentModel.ListBindable(false)]
public sealed class OleDbParameterCollection : MarshalByRefObject, System.Collections.IList, System.Data.IDataParameterCollection
[System.ComponentModel.ListBindable(false)]
public sealed class OleDbParameterCollection : System.Data.Common.DbParameterCollection
[<System.ComponentModel.ListBindable(false)>]
type OleDbParameterCollection = class
inherit MarshalByRefObject
interface IDataParameterCollection
interface IList
interface ICollection
interface IEnumerable
[<System.ComponentModel.ListBindable(false)>]
type OleDbParameterCollection = class
inherit DbParameterCollection
Public NotInheritable Class OleDbParameterCollection
Inherits MarshalByRefObject
Implements IDataParameterCollection, IList
Public NotInheritable Class OleDbParameterCollection
Inherits DbParameterCollection
- 継承
- 継承
- 属性
- 実装
例
次の例では、OleDbDataAdapter内のOleDbParameterCollection コレクションを通じてOleDbParameterの複数のインスタンスを作成します。 これらのパラメーターは、データ ソース内のデータを選択し、 DataSetにデータを配置するために使用されます。 この例では、適切なスキーマ、コマンド、接続を使用して、 DataSet と OleDbDataAdapter が既に作成されていることを前提としています。
public DataSet GetDataSetFromAdapter(
DataSet dataSet, string connectionString, string queryString)
{
using (OleDbConnection connection =
new OleDbConnection(connectionString))
{
OleDbDataAdapter adapter =
new OleDbDataAdapter(queryString, connection);
// Set the parameters.
adapter.SelectCommand.Parameters.Add(
"@CategoryName", OleDbType.VarChar, 80).Value = "toasters";
adapter.SelectCommand.Parameters.Add(
"@SerialNum", OleDbType.Integer).Value = 239;
// Open the connection and fill the DataSet.
try
{
connection.Open();
adapter.Fill(dataSet);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
// The connection is automatically closed when the
// code exits the using block.
}
return dataSet;
}
Public Function GetDataSetFromAdapter( _
ByVal dataSet As DataSet, ByVal connectionString As String, _
ByVal queryString As String) As DataSet
Using connection As New OleDbConnection(connectionString)
Dim adapter As New OleDbDataAdapter(queryString, connection)
' Set the parameters.
adapter.SelectCommand.Parameters.Add( _
"@CategoryName", OleDbType.VarChar, 80).Value = "toasters"
adapter.SelectCommand.Parameters.Add( _
"@SerialNum", OleDbType.Integer).Value = 239
' Open the connection and fill the DataSet.
Try
connection.Open()
adapter.Fill(dataSet)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
' The connection is automatically closed when the
' code exits the Using block.
End Using
Return dataSet
End Function
注釈
コレクション内のパラメーターの数は、コマンド テキスト内のパラメーター プレースホルダーの数と同じである必要があります。そうしないと、OLE DB の.NET Framework Data Providerでエラーが発生する可能性があります。
プロパティ
| 名前 | 説明 |
|---|---|
| Count |
OleDbParameterCollection内の要素の数を含む整数を返します。 Read-only. |
| IsFixedSize |
OleDbParameterCollectionに固定サイズがあるかどうかを示す値を取得します。 Read-only. |
| IsReadOnly |
OleDbParameterCollectionが読み取り専用かどうかを示す値を取得します。 |
| IsSynchronized |
OleDbParameterCollectionが同期されているかどうかを示す値を取得します。 Read-only. |
| Item[Int32] |
指定したインデックス位置にある OleDbParameter を取得または設定します。 |
| Item[String] |
指定した名前の OleDbParameter を取得または設定します。 |
| SyncRoot |
OleDbParameterCollectionへのアクセスを同期するために使用できるオブジェクトを取得します。 Read-only. |
メソッド
明示的なインターフェイスの実装
| 名前 | 説明 |
|---|---|
| IDataParameterCollection.Item[String] |
指定したインデックス位置にあるパラメーターを取得または設定します。 (継承元 DbParameterCollection) |
| IList.Item[Int32] |
指定したインデックス位置にある要素を取得または設定します。 (継承元 DbParameterCollection) |
拡張メソッド
| 名前 | 説明 |
|---|---|
| AsParallel(IEnumerable) |
クエリの並列化を有効にします。 |
| AsQueryable(IEnumerable) |
IEnumerable を IQueryableに変換します。 |
| Cast<TResult>(IEnumerable) |
IEnumerable の要素を指定した型にキャストします。 |
| OfType<TResult>(IEnumerable) |
指定した型に基づいて、IEnumerable の要素をフィルター処理します。 |