Placeholders for parameters in SQL statements are indicated by the ? character. For any INSERT, UPDATE, or DELETE, each ? is referenced according to its ordinal position in the command's parameters collection. For example, the first ? is referred to as 0, and the second as 1.
Prérequis
There are no prerequisites for this task.
Declare a ULCommand.
ULCommand cmd; |
Assign a statement to the ULCommand object.
cmd = conn.CreateCommand(); cmd.CommandText = "UPDATE MyTable SET MyColumn1 = ? WHERE MyColumn2 = ?"; |
Assign input parameter values for the statement.
String newValue; String oldValue; cmd.Parameters.Clear(); // assign values cmd.Parameters.Add("", newValue); cmd.Parameters.Add("", oldValue); |
Execute the statement.
int rowsUpdated = cmd.ExecuteNonQuery(); |
If you are using explicit transactions, commit the change.
myTransaction.Commit(); |
![]() |
Discuter à propos de cette page dans DocCommentXchange.
|
Copyright © 2013, SAP AG ou société affiliée SAP - SAP Sybase SQL Anywhere 16.0 |