Export (0) Print
Expand All

IDataParameterCollection Interface

Collects all parameters relevant to a Command object and their mappings to DataSet columns, and is implemented by .NET Framework data providers that access data sources.

For a list of all members of this type, see IDataParameterCollection Members.

[Visual Basic]
Public Interface IDataParameterCollection
   Inherits IList, ICollection, IEnumerable
[C#]
public interface IDataParameterCollection : IList, ICollection,
   IEnumerable
[C++]
public __gc __interface IDataParameterCollection : public IList,
   ICollection, IEnumerable
[JScript]
public interface IDataParameterCollection implements IList,
   ICollection, IEnumerable

Classes that Implement IDataParameterCollection

Class Description
OdbcParameterCollection Represents a collection of parameters relevant to an OdbcCommand as well as their respective mappings to columns in a DataSet. This class cannot be inherited.
OleDbParameterCollection Represents a collection of parameters relevant to an OleDbCommand as well as their respective mappings to columns in a DataSet.
OracleParameterCollection Represents a collection of parameters relevant to an OracleCommand as well as their respective mappings to columns in a DataSet. This class cannot be inherited.
SqlCeParameterCollection Collects all parameters relevant to a SqlCeCommand as well as their respective mappings to DataSet columns.
SqlParameterCollection Represents a collection of parameters relevant to a SqlCommand as well as their respective mappings to columns in a DataSet. This class cannot be inherited.

Remarks

The IDataParameterCollection interface allows an inheriting class to implement a Parameter collection. For more information about Parameter classes, see Using Stored Procedures with a Command. For more information about implementing .NET Framework data providers, see Implementing a .NET Framework Data Provider.

An application does not create an instance of the IDataParameterCollection interface directly, but creates an instance of a class that inherits IDataParameterCollection.

Classes that inherit IDataParameterCollection must implement the inherited members, and typically define additional members to add provider-specific functionality. For example, the IDataParameterCollection interface defines one implementation of the RemoveAt method. In turn, the OleDbParameterCollection class inherits this method, and defines two additional overloads of RemoveAt.

Notes to Implementers:  When you inherit from the IDataParameterCollection interface, you should implement the following constructor:

Item Description
PrvParameterCollection() Creates an empty PrvParameterCollection class.

Example

[Visual Basic, C#, C++] The following example creates multiple instances of the derived class, SqlParameter, through the SqlParameterCollection collection within the SqlDataAdapter. These parameters are used to select data from the data source and place the data in the DataSet. This example assumes that a DataSet and a SqlDataAdapter have already been created with the appropriate schema, commands, and connection.

[Visual Basic] 
Public Sub AddSqlParameters()
    ' ...
    ' create myDataSet and myDataAdapter
    ' ...
    myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", SqlDbType.VarChar, 80).Value = "toasters"
    myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", SqlDbType.Int).Value = 239
    
    myDataAdapter.Fill(myDataSet)
End Sub 'AddSqlParameters 

[C#] 
public void AddSqlParameters() 
{
// ...
// create myDataSet and myDataAdapter
// ...

  myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", SqlDbType.VarChar, 80).Value = "toasters";
  myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", SqlDbType.Int).Value = 239;
  myDataAdapter.Fill(myDataSet);

}

[C++] 
public:
void AddSqlParameters() 
{
// ...
// create myDataSet and myDataAdapter
// ...

  myDataAdapter->SelectCommand->Parameters->Add(S"@CategoryName", SqlDbType::VarChar, 80)->Value = S"toasters";
  myDataAdapter->SelectCommand->Parameters->Add(S"@SerialNum", SqlDbType::Int)->Value = __box(239);
  myDataAdapter->Fill(myDataSet);

}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Data

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

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

See Also

IDataParameterCollection Members | System.Data Namespace

Show:
© 2014 Microsoft