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.
Prerequisites
There are no prerequisites for this task.
Declare a ULCommand.
ULCommand cmd; |
Assign a SQL statement to the ULCommand object.
cmd = conn.CreateCommand(); cmd.CommandText = "INSERT INTO MyTable(MyColumn) values (?)"; |
Assign input parameter values for the statement.
The following code shows a string parameter.
String newValue; cmd.Parameters.Clear(); // assign value cmd.Parameters.Add("", newValue); |
Execute the statement.
The return value indicates the number of rows affected by the statement.
int rowsInserted = cmd.ExecuteNonQuery(); |
If you are using explicit transactions, commit the change.
myTransaction.Commit(); |
![]() |
Discuss this page in DocCommentXchange.
|
Copyright © 2014, SAP AG or an SAP affiliate company. - SAP Sybase SQL Anywhere 16.0 |