With UltraLite, you can perform SQL data manipulation language operations. These operations are performed using the ULCommand.ExecuteNonQuery method.
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.
Declare a ULCommand.
ULCommand cmd; |
Assign a SQL statement to the ULCommand object.
cmd = conn.CreateCommand(); cmd.Command = "INSERT INTO MyTable(MyColumn) values (?)"; |
Assign input parameter values for the statement.
The following code shows a string parameter.
String newValue; // 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(); |
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.
Declare a ULCommand.
ULCommand cmd; |
Assign a statement to the ULCommand object.
cmd = conn.CreateCommand(); cmd.Command = "UPDATE MyTable SET MyColumn1 = ? WHERE MyColumn2 = ?"; |
Assign input parameter values for the statement.
String newValue; String oldValue; // 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(); |
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.
Declare a ULCommand.
ULCommand cmd; |
Assign a statement to the ULCommand object.
cmd = conn.CreateCommand(); cmd.Command = "DELETE FROM MyTable WHERE MyColumn = ?"; |
Assign input parameter values for the statement.
String deleteValue; // assign value cmd.Parameters.add("", deleteValue); |
Execute the statement.
int rowsDeleted = cmd.ExecuteNonQuery(); |
If you are using explicit transactions, commit the change.
myTransaction.Commit(); |
Discuss this page in DocCommentXchange.
|
Copyright © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1 |