Updates records in the database. The Update method overwrites existing records in the database instead of adding new ones.
Note: the third parameter must be specified for the method to be executed successfully.
Syntax
DB.Update(table, data, keyvalues);
// or
DB.Update(table, data, where);
Arguments
table
the table where you want to update the data.
data
an array of values that overwrites the existing record.
keyvalues
an array of key values that define the condition for the Update query.
where
the condition for the Update query.
Return value
No return value.
Example
// Update the record with id=50 in the 'Cars' table
dynamic data = XVar.Array();
dynamic keyvalues = XVar.Array();
data["make"]="Toyota";
data["model"]="RAV4";
data["price"]=16000;
keyvalues["id"]=50;
DB.Update("cars", data, keyvalues);
Alternative syntax:
// Update a record in the 'Cars' table where id=50
dynamic data = XVar.Array();
data["make"]="Toyota";
data["model"]="RAV4";
data["price"]=16000;
DB.Update("cars", data, "id=50");
See also: