OleDbParameterCollection 類別

定義

表示與 OleDbCommand 相關之參數及其與 DataSet 中資料行之個別對應的集合。Represents a collection of parameters relevant to an OleDbCommand as well as their respective mappings to columns in a DataSet.

public ref class OleDbParameterCollection sealed : System::Data::Common::DbParameterCollection
public ref class OleDbParameterCollection sealed : MarshalByRefObject, System::Collections::IList, System::Data::IDataParameterCollection
public sealed class OleDbParameterCollection : 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
type OleDbParameterCollection = class
    inherit 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 DbParameterCollection
Public NotInheritable Class OleDbParameterCollection
Inherits MarshalByRefObject
Implements IDataParameterCollection, IList
繼承
OleDbParameterCollection
繼承
繼承
OleDbParameterCollection
屬性
實作

範例

下列範例會 OleDbParameter 透過中的集合建立多個實例 OleDbParameterCollection OleDbDataAdapterThe following example creates multiple instances of OleDbParameter through the OleDbParameterCollection collection within the OleDbDataAdapter. 這些參數用來選取資料來源中的資料,並將資料放在中 DataSetThese parameters are used to select data within the data source and place the data in the DataSet. 這個範例假設 DataSet OleDbDataAdapter 已經使用適當的架構、命令和連接來建立和。This example assumes that a DataSet and an OleDbDataAdapter have already been created with the appropriate schema, commands, and connection.

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 可能會引發錯誤。The number of parameters in the collection must equal the number of parameter placeholders within the command text, otherwise the .NET Framework Data Provider for OLE DB might raise an error.

屬性

Count

傳回包含 OleDbParameterCollection 中之項目數目的整數。Returns an integer that contains the number of elements in the OleDbParameterCollection. 唯讀。Read-only.

IsFixedSize

取得值,指出 OleDbParameterCollection 是否有固定的大小。Gets a value that indicates whether the OleDbParameterCollection has a fixed size. 唯讀。Read-only.

IsReadOnly

取得值,這個值表示 OleDbParameterCollection 是否為唯讀。Gets a value that indicates whether the OleDbParameterCollection is read-only.

IsSynchronized

取得值,表示 OleDbParameterCollection 是否同步處理。Gets a value that indicates whether the OleDbParameterCollection is synchronized. 唯讀。Read-only.

Item[Int32]

取得或設定在指定索引處的 OleDbParameterGets or sets the OleDbParameter at the specified index.

Item[String]

取得或設定具有指定之名稱的 OleDbParameterGets or sets the OleDbParameter with the specified name.

SyncRoot

取得可用以同步存取 OleDbParameterCollection 的物件。Gets an object that can be used to synchronize access to the OleDbParameterCollection. 唯讀。Read-only.

方法

Add(Object)

將指定的 OleDbParameter 物件加入至 OleDbParameterCollectionAdds the specified OleDbParameter object to the OleDbParameterCollection.

Add(OleDbParameter)

將指定的 OleDbParameter 加入至 OleDbParameterCollectionAdds the specified OleDbParameter to the OleDbParameterCollection.

Add(String, Object)
已過時。

加入 OleDbParameter 至提供參數名稱和值的 OleDbParameterCollectionAdds an OleDbParameter to the OleDbParameterCollection given the parameter name and value.

Add(String, OleDbType)

在提供參數名稱和資料型別的情況下,將 OleDbParameter 加入至 OleDbParameterCollectionAdds an OleDbParameter to the OleDbParameterCollection, given the parameter name and data type.

Add(String, OleDbType, Int32)

OleDbParameter 加入至提供參數名稱、資料型別和資料行長度的 OleDbParameterCollectionAdds an OleDbParameter to the OleDbParameterCollection given the parameter name, data type, and column length.

Add(String, OleDbType, Int32, String)

OleDbParameter 加入至提供參數名稱、資料型別、資料行長度和來源資料行名稱的 OleDbParameterCollectionAdds an OleDbParameter to the OleDbParameterCollection given the parameter name, data type, column length, and source column name.

AddRange(Array)

將值陣列加入至 OleDbParameterCollection 結尾。Adds an array of values to the end of the OleDbParameterCollection.

AddRange(OleDbParameter[])

OleDbParameter 值陣列加入至 OleDbParameterCollection 結尾。Adds an array of OleDbParameter values to the end of the OleDbParameterCollection.

AddWithValue(String, Object)

將值加入至 OleDbParameterCollection 結尾。Adds a value to the end of the OleDbParameterCollection.

Clear()

OleDbParameter 移除所有 OleDbParameterCollection 物件。Removes all OleDbParameter objects from the OleDbParameterCollection.

Contains(Object)

判斷指定的 Object 是否在這個 OleDbParameterCollection 中。Determines whether the specified Object is in this OleDbParameterCollection.

Contains(OleDbParameter)

判斷指定的 OleDbParameter 是否在這個 OleDbParameterCollection 中。Determines whether the specified OleDbParameter is in this OleDbParameterCollection.

Contains(String)

判斷指定的 String 是否在這個 OleDbParameterCollection 中。Determines whether the specified String is in this OleDbParameterCollection.

CopyTo(Array, Int32)

將目前 OleDbParameterCollection 的所有項目複製到指定的一維 Array,從指定的目的 Array 索引開始。Copies all the elements of the current OleDbParameterCollection to the specified one-dimensional Array starting at the specified destination Array index.

CopyTo(OleDbParameter[], Int32)

將目前 OleDbParameterCollection 的所有項目複製到指定的 OleDbParameterCollection,從指定的目的索引開始。Copies all the elements of the current OleDbParameterCollection to the specified OleDbParameterCollection starting at the specified destination index.

CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(繼承來源 MarshalByRefObject)
Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetEnumerator()

傳回在 OleDbParameterCollection 中逐一查看的列舉值。Returns an enumerator that iterates through the OleDbParameterCollection.

GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetLifetimeService()
已過時。

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(繼承來源 MarshalByRefObject)
GetParameter(Int32)

傳回位於此集合指定索引處的 DbParameter 物件。Returns the DbParameter object at the specified index in the collection.

(繼承來源 DbParameterCollection)
GetParameter(String)

傳回具有指定名稱的 DbParameter 物件。Returns DbParameter the object with the specified name.

(繼承來源 DbParameterCollection)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
IndexOf(Object)

集合中指定之 Object 的位置。The location of the specified Object within the collection.

IndexOf(OleDbParameter)

取得集合中指定的 OleDbParameter 位置。Gets the location of the specified OleDbParameter within the collection.

IndexOf(String)

取得集合中具有指定名稱之指定 OleDbParameter 的位置。Gets the location of the specified OleDbParameter with the specified name.

InitializeLifetimeService()
已過時。

取得存留期服務物件,以控制這個執行個體的存留期原則。Obtains a lifetime service object to control the lifetime policy for this instance.

(繼承來源 MarshalByRefObject)
Insert(Int32, Object)

Object 插入 OleDbParameterCollection中指定的索引處。Inserts a Object into the OleDbParameterCollection at the specified index.

Insert(Int32, OleDbParameter)

OleDbParameter 物件插入 OleDbParameterCollection 的指定索引處。Inserts a OleDbParameter object into the OleDbParameterCollection at the specified index.

MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。Creates a shallow copy of the current MarshalByRefObject object.

(繼承來源 MarshalByRefObject)
Remove(Object)

Object 移除 OleDbParameterCollection 物件。Removes the Object object from the OleDbParameterCollection.

Remove(OleDbParameter)

OleDbParameter 中移除 OleDbParameterCollectionRemoves the OleDbParameter from the OleDbParameterCollection.

RemoveAt(Int32)

OleDbParameter 的指定索引處移除 OleDbParameterCollectionRemoves the OleDbParameter from the OleDbParameterCollection at the specified index.

RemoveAt(String)

OleDbParameter 的指定參數名稱處移除 OleDbParameterCollectionRemoves the OleDbParameter from the OleDbParameterCollection at the specified parameter name.

SetParameter(Int32, DbParameter)

將指定索引處的 DbParameter 物件設定為新值。Sets the DbParameter object at the specified index to a new value.

(繼承來源 DbParameterCollection)
SetParameter(String, DbParameter)

將具有指定名稱的 DbParameter 物件設定為新值。Sets the DbParameter object with the specified name to a new value.

(繼承來源 DbParameterCollection)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

明確介面實作

ICollection.IsSynchronized

取得值,這個值表示對 ICollection 的存取是否同步 (安全執行緒)。Gets a value indicating whether access to the ICollection is synchronized (thread safe).

(繼承來源 DbParameterCollection)
IDataParameterCollection.Item[String]

在指定索引位置上取得或設定參數。Gets or sets the parameter at the specified index.

(繼承來源 DbParameterCollection)
IList.Add(Object)

如需這個成員的說明,請參閱 Add(Object)For a description of this member, see Add(Object).

(繼承來源 DbParameterCollection)
IList.Contains(Object)

如需這個成員的說明,請參閱 Contains(Object)For a description of this member, see Contains(Object).

(繼承來源 DbParameterCollection)
IList.IndexOf(Object)

如需這個成員的說明,請參閱 IndexOf(Object)For a description of this member, see IndexOf(Object).

(繼承來源 DbParameterCollection)
IList.Insert(Int32, Object)

如需這個成員的說明,請參閱 Insert(Int32, Object)For a description of this member, see Insert(Int32, Object).

(繼承來源 DbParameterCollection)
IList.IsFixedSize

取得值,指出 IList 是否有固定的大小。Gets a value indicating whether the IList has a fixed size.

(繼承來源 DbParameterCollection)
IList.IsReadOnly

取得值,指出 IList 是否唯讀。Gets a value indicating whether the IList is read-only.

(繼承來源 DbParameterCollection)
IList.Item[Int32]

在指定的索引位置上取得或設定項目。Gets or sets the element at the specified index.

(繼承來源 DbParameterCollection)
IList.Remove(Object)

如需這個成員的說明,請參閱 Remove(Object)For a description of this member, see Remove(Object).

(繼承來源 DbParameterCollection)

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryableConverts an IEnumerable to an IQueryable.

適用於

另請參閱