OleDbParameterCollection OleDbParameterCollection OleDbParameterCollection OleDbParameterCollection Class

Definition

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
[System.ComponentModel.ListBindable(false)]
public sealed class OleDbParameterCollection : System.Data.Common.DbParameterCollection
type OleDbParameterCollection = class
    inherit DbParameterCollection
Public NotInheritable Class OleDbParameterCollection
Inherits DbParameterCollection
Inheritance
OleDbParameterCollectionOleDbParameterCollectionOleDbParameterCollectionOleDbParameterCollection
Attributes

Examples

The following example creates multiple instances of OleDbParameter through the OleDbParameterCollection collection within the OleDbDataAdapter. These parameters are used to select data within the data source and place the data in the DataSet. 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

Remarks

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.

Properties

Count Count Count Count

Returns an integer that contains the number of elements in the OleDbParameterCollection. Read-only.

IsFixedSize IsFixedSize IsFixedSize IsFixedSize

Gets a value that indicates whether the OleDbParameterCollection has a fixed size. Read-only.

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

Gets a value that indicates whether the OleDbParameterCollection is read-only.

IsSynchronized IsSynchronized IsSynchronized IsSynchronized

Gets a value that indicates whether the OleDbParameterCollection is synchronized. Read-only.

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

Gets or sets the OleDbParameter at the specified index.

Item[String] Item[String] Item[String] Item[String]

Gets or sets the OleDbParameter with the specified name.

SyncRoot SyncRoot SyncRoot SyncRoot

Gets an object that can be used to synchronize access to the OleDbParameterCollection. Read-only.

Methods

Add(Object) Add(Object) Add(Object) Add(Object)

Adds the specified OleDbParameter object to the OleDbParameterCollection.

Add(OleDbParameter) Add(OleDbParameter) Add(OleDbParameter) Add(OleDbParameter)

Adds the specified OleDbParameter to the OleDbParameterCollection.

Add(String, Object) Add(String, Object) Add(String, Object) Add(String, Object)

Adds an OleDbParameter to the OleDbParameterCollection given the parameter name and value.

Add(String, OleDbType) Add(String, OleDbType) Add(String, OleDbType) Add(String, OleDbType)

Adds an OleDbParameter to the OleDbParameterCollection, given the parameter name and data type.

Add(String, OleDbType, Int32) Add(String, OleDbType, Int32) Add(String, OleDbType, Int32) Add(String, OleDbType, Int32)

Adds an OleDbParameter to the OleDbParameterCollection given the parameter name, data type, and column length.

Add(String, OleDbType, Int32, String) Add(String, OleDbType, Int32, String) Add(String, OleDbType, Int32, String) Add(String, OleDbType, Int32, String)

Adds an OleDbParameter to the OleDbParameterCollection given the parameter name, data type, column length, and source column name.

AddRange(Array) AddRange(Array) AddRange(Array) AddRange(Array)

Adds an array of values to the end of the OleDbParameterCollection.

AddRange(OleDbParameter[]) AddRange(OleDbParameter[]) AddRange(OleDbParameter[]) AddRange(OleDbParameter[])

Adds an array of OleDbParameter values to the end of the OleDbParameterCollection.

AddWithValue(String, Object) AddWithValue(String, Object) AddWithValue(String, Object) AddWithValue(String, Object)

Adds a value to the end of the OleDbParameterCollection.

Clear() Clear() Clear() Clear()

Removes all OleDbParameter objects from the OleDbParameterCollection.

Contains(Object) Contains(Object) Contains(Object) Contains(Object)

Determines whether the specified Object is in this OleDbParameterCollection.

Contains(OleDbParameter) Contains(OleDbParameter) Contains(OleDbParameter) Contains(OleDbParameter)

Determines whether the specified OleDbParameter is in this OleDbParameterCollection.

Contains(String) Contains(String) Contains(String) Contains(String)

Determines whether the specified String is in this OleDbParameterCollection.

CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32)

Copies all the elements of the current OleDbParameterCollection to the specified one-dimensional Array starting at the specified destination Array index.

CopyTo(OleDbParameter[], Int32) CopyTo(OleDbParameter[], Int32) CopyTo(OleDbParameter[], Int32) CopyTo(OleDbParameter[], Int32)

Copies all the elements of the current OleDbParameterCollection to the specified OleDbParameterCollection starting at the specified destination index.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

Returns an enumerator that iterates through the OleDbParameterCollection.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
IndexOf(Object) IndexOf(Object) IndexOf(Object) IndexOf(Object)

The location of the specified Object within the collection.

IndexOf(OleDbParameter) IndexOf(OleDbParameter) IndexOf(OleDbParameter) IndexOf(OleDbParameter)

Gets the location of the specified OleDbParameter within the collection.

IndexOf(String) IndexOf(String) IndexOf(String) IndexOf(String)

Gets the location of the specified OleDbParameter with the specified name.

InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
Insert(Int32, Object) Insert(Int32, Object) Insert(Int32, Object) Insert(Int32, Object)

Inserts a Object into the OleDbParameterCollection at the specified index.

Insert(Int32, OleDbParameter) Insert(Int32, OleDbParameter) Insert(Int32, OleDbParameter) Insert(Int32, OleDbParameter)

Inserts a OleDbParameter object into the OleDbParameterCollection at the specified index.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
Remove(Object) Remove(Object) Remove(Object) Remove(Object)

Removes the Object object from the OleDbParameterCollection.

Remove(OleDbParameter) Remove(OleDbParameter) Remove(OleDbParameter) Remove(OleDbParameter)

Removes the OleDbParameter from the OleDbParameterCollection.

RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)

Removes the OleDbParameter from the OleDbParameterCollection at the specified index.

RemoveAt(String) RemoveAt(String) RemoveAt(String) RemoveAt(String)

Removes the OleDbParameter from the OleDbParameterCollection at the specified parameter name.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also