Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SAP Sybase SQL Anywhere 16.0 » UltraLite - .NET Programming » UltraLite.NET application development » Data creation and modification using SQL statements » Data modification using INSERT, UPDATE, and DELETE


Updating a row in a table

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.


There are no prerequisites for this task.

  1. Declare a ULCommand.

    ULCommand cmd;
  2. Assign a statement to the ULCommand object.

    cmd = conn.CreateCommand();
    cmd.CommandText = "UPDATE MyTable SET MyColumn1 = ? WHERE MyColumn2 = ?";
  3. Assign input parameter values for the statement.

    String newValue;
    String oldValue;
    // assign values
    cmd.Parameters.Add("", newValue);
    cmd.Parameters.Add("", oldValue);
  4. Execute the statement.

    int rowsUpdated = cmd.ExecuteNonQuery();
  5. If you are using explicit transactions, commit the change.



Row entries from MyTable are updated where the MyColumn1 value is an empty string. In this scenario, the MyColumn2 value is also set to an empty string.