This documentation is archived and is not being maintained.

OleDbParameterCollection Class

Represents a collection of parameters relevant to an OleDbCommand as well as their respective mappings to columns in a DataSet.

Namespace:  System.Data.OleDb
Assembly:  System.Data (in System.Data.dll)

'Declaration
<ListBindableAttribute(False)> _
Public NotInheritable Class OleDbParameterCollection _
	Inherits DbParameterCollection
'Usage
Dim instance As OleDbParameterCollection

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.

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 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

System.Object
  System.MarshalByRefObject
    System.Data.Common.DbParameterCollection
      System.Data.OleDb.OleDbParameterCollection

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: