DB2 10.5 for Linux, UNIX, and Windows

DB2ParameterCollection Class

Represents a collection of parameters relevant to a DB2Command as well as their mappings to columns in a DataSet.

Namespace:
IBM.Data.DB2
Assembly:
IBM.Data.DB2 (in IBM.Data.DB2.dll)

.NET Framework 2.0 3.0, 3.5, and 4.0 Inheritance hierarchy

System.Object
   System.MarshalByRefObject
      System.Data.Common.DbParameterCollection
         IBM.Data.DB2.DB2ParameterCollection

.NET Framework 2.0 3.0, 3.5, and 4.0 Syntax

[Visual Basic]
NotInheritable Public Class DB2ParameterCollection
   Inherits DbParameterCollection
   Implements IDataParameterCollection, IList, ICollection, _
   IEnumerable
[C#]
public sealed class DB2ParameterCollection : DbParameterCollection,
   IDataParameterCollection, IList, ICollection, IEnumerable
[C++]
public __gc __sealed class DB2ParameterCollection : public
   DbParameterCollection, IDataParameterCollection, IList,
   ICollection,
   IEnumerable
[JScript]
public class DB2ParameterCollection extends DbParameterCollection
   implements IDataParameterCollection, IList, ICollection,
   IEnumerable

Exceptions

Exception type Condition
DB2®Exception Wrong number of parameters. The number of parameters in the collection must be equal to the number of parameter placeholders within the command text.

Example

[Visual Basic, C#] The following example assumes the existence of a table named MyTable and a stored procedure named MyProcedure. These objects are defined with the following statements:

create table MyTable (column1 int)
create procedure MyProcedure (p1 int ) language sql LABEL1: 
  begin insert into MyTable values (p1); end

The example calls the MyProcedure stored procedure.

[Visual Basic]
Public Sub AddDB2Parameters()
    // Create myConnection and myCommand.

    myCommand.CommandText = "{call MyProcedure (?)}"
    myCommand.Parameters.Add("p1",DB2Type.Integer).Value = 100
    myCommand.ExecuteNonQuery()

End Sub 'AddDB2Parameters
[C#]
public void AddDB2Parameters()
  {
      // Create myConnection and myCommand.

         myCommand.CommandText = "{call MyProcedure (?)}";
         myCommand.Parameters.Add("p1",DB2Type.Integer).Value = 100;
         myCommand.ExecuteNonQuery();
  }

Thread safety

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