Please enable JavaScript to view this site.

Navigation: Advanced topics > Events > Sample events > Database

Update multiple tables

Scroll Prev Next More

 

To update two joined tables, use the following code in the Add page: Before record added and/or Edit page: Before record updated events.

 

 

 

string sql = "update othertable set joinedfield=" + values["joinedfield"].ToString() + " ... ";
CommonFunctions.db_exec(sql, null);
values.Remove("joinedfield");

 

To update master and details tables, use the following code for the details table in the Add page: Before record added and/or Edit page: Before record updated events:

 

dynamic fieldValues = XVar.Array();
dynamic keyValues = XVar.Array();
fieldValues["Field1"] = values["Field1"];
keyValues["OrderID"] = values["OrderID"];
DB.Update("DetailTable", fieldValues, keyValues);
values.Remove("Field1");
return true;

 

"Field1" is a field in the details table and "OrderID" is the linked field in the master table.

See also:

Database API

Database API: DB::Exec

Master-details relationship between tables

Update multiple records on the List page