将指定的 DB2Parameter 添加至集合。
名称 | 描述 |
---|---|
Add(Object) As Integer Implements IList.Add | 将指定的 DB2Parameter 添加至 DB2Command。 |
Add(DB2Parameter) As DB2Parameter | 将指定的 DB2Parameter 添加至 DB2ParameterCollection。 |
Add(String, Object) As DB2Parameter | 在给定参数名和值的情况下,将 DB2Parameter 添加至 DB2Command。 |
Add(String, DB2Type) As DB2Parameter | 在给定参数名和数据类型的情况下,将 DB2Parameter 添加至 DB2Command。 |
Add(String, DB2Type, Integer) As DB2Parameter | 在给定参数名、数据类型和列宽的情况下,将 DB2Parameter 添加至 DB2Command。 |
Add(String, DB2Type, Integer, String) As DB2Parameter | 在给定参数名、数据类型、列宽和源列名的情况下,将 DB2Parameter 添加至 DB2Command。 |
[Visual Basic, C#] 以下示例将为命令创建 DB2Command 和 DB2ParameterCollection,并将 DB2Parameter 的实例添加至该集合。
[Visual Basic]
Public Sub CreateDB2ParamColl(myConn As DB2Connection)
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, "EMPNO")
End Sub 'CreateDB2ParamColl
[C#]
public void 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, "EMPNO");
}