DB2ParameterCollection.Add (String, DB2Type, Int32) Method
Adds a DB2Parameter to the DB2Command given the parameter name, data type, and column width.
- Namespace:
IBM.Data.DB2
- Assembly:
IBM.Data.DB2
(inIBM.Data.DB2.dll
)
Syntax
[Visual Basic]
Overloads Public Function Add( _
ByVal parameterName As String, _
ByVal DB2Type As DB2Type
, _
ByVal size As Integer _
) As DB2Parameter
[C#]
public DB2Parameter
Add(
string parameterName,
DB2Type
DB2Type,
int size
);
[C++]
public: DB2Parameter
* Add(
String* parameterName,
DB2Type
DB2Type,
int size
);
[JScript]
public function Add(
parameterName : String,
DB2Type : DB2Type
,
size : int
) : DB2Parameter
;
Parameters
- parameterName
- The name of the parameter.
- DB2Type
- One of the DB2®Type values.
- size
- The width of the column.
Return value
The new DB2Parameter object.
Example
[Visual Basic, C#] The following example creates a DB2ParameterCollection , adds an instance of DB2Parameter to the collection, and returns a reference to the new DB2Parameter.
[Visual Basic]
Public Function CreateDB2ParamColl(myConn As DB2Connection) As DB2Parameter
Dim myCommand As DB2Command = New DB2Command(
"SELECT * FROM EMPLOYEE WHERE EMPNO = ?", myConn)
Dim myParamCollection As DB2ParameterCollection = myCommand.Parameters
Dim myNewParameter As DB2Parameter = myParamCollection.Add(
"EMPNO", DB2Type.VarChar, 6)
Return myParm
End Function 'CreateDB2ParamColl
[C#]
public DB2Parameter CreateDB2ParamColl(DB2Connection myConn) {
DB2Command myCommand = new DB2Command(
"SELECT * FROM EMPLOYEE WHERE EMPNO = ?", myConn);
DB2ParameterCollection myParamCollection = myCommand.Parameters;
DB2Parameter myNewParameter = myParamCollection.Add(
"EMPNO", DB2Type.VarChar, 6);
return myParm; }