'Declaration Public Shadows ReadOnly Property Parameters As DB2ParameterCollection
public new DB2ParameterCollection Parameters {get;}
'Declaration Public Shadows ReadOnly Property Parameters As DB2ParameterCollection
public new DB2ParameterCollection Parameters {get;}
static void CreateCommand(DB2Connection db2Connection, string mySelectQuery, DB2Parameter[] myParamArray) { DB2Command db2Command = new DB2Command(mySelectQuery, db2Connection); string myMessage = ""; for (int i = 0; i < myParamArray.Length; i++) { db2Command.Parameters.Add(myParamArray[i]); myMessage += db2Command.Parameters[i].ToString() + "\n"; } Console.Write(myMessage); try { db2Connection.Open(); db2Command.ExecuteNonQuery(); } finally { db2Connection.Close(); } } static void Main(string[] args) { DB2Parameter[] myParams = new DB2Parameter[] { new DB2Parameter("DeptNo", 10), new DB2Parameter("DName", "COUNTING") }; DB2Connection db2Connection1 = new DB2Connection( "user id=db2admin;server=db2;database=SAMPLE;"); CreateCommand(db2Connection1,"UPDATE Dept SET DName = :DName WHERE DeptNo = :DeptNo",myParams); }
Public Sub CreateCommand(ByVal db2Connection As Devart.Data.DB2.DB2Connection, _ ByVal mySelectQuery As String, ByVal myParamArray() As Devart.Data.DB2.DB2Parameter) Dim db2Command As New Devart.Data.DB2.DB2Command(mySelectQuery, db2Connection) Dim myMessage As String = "" Dim i As Integer For i = 0 To (myParamArray.Length - 1) db2Command.Parameters.Add(myParamArray(i)) myMessage = String.Concat(myMessage, " ", db2Command.Parameters(i).ToString()) Next Console.WriteLine(myMessage) Try db2Connection.Open() db2Command.ExecuteNonQuery() Finally db2Connection.Close() End Try End Sub Sub Main() Dim myP1 As New Devart.Data.DB2.DB2Parameter myP1.ParameterName = "DeptNo" myP1.Value = 10 Dim myP2 As New Devart.Data.DB2.DB2Parameter myP2.ParameterName = "DName" myP2.Value = "ACCOUNTING" Dim myParams(1) As Devart.Data.DB2.DB2Parameter myParams(0) = myP1 myParams(1) = myP2 Dim db2Connection1 As New Devart.Data.DB2.DB2Connection( _ "user id=db2admin;server=db2;database=SAMPLE;") CreateCommand(db2Connection1, "UPDATE Dept SET DName = :DName WHERE DeptNo = :DeptNo", myParams) End Sub
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2