|
|
Syntax
cmdUpdate.setFilter(filter)
Arguments |
Description |
filter |
Sets
the filter for the cmdUpdate object,
overwriting any prior filter setting. An exception
is thrown if an invalid filter is provided. |
|
Returns
Return
value is undefined.
Description
The setFilter() method specifies the filter to be used by the cmdUpdate.execute()method. The filter is used to designate which portion of the data table are affected by an update. The filter can be an object, object literal, or use filter string syntax to denote whole columns or just portions of columns. To review filter syntax, see the link above.
Example
The following three examples demonstrate three different ways of specifying the filter argument for the setFilter() method. The first example uses an object to set the filter, the second uses an object literal, and the third uses a string. To review filter syntax see the discussion in Data Access Method Arguments.
//Example #1: This example uses an object to
//update the Email field for records where
//the LastName field has the value "Smith"
//and the FirstName field has the value "Mary".
var upd = new cmdUpdate("AddressBook");
var filt = new Object();
filt.LastName = "Smith";
filt.FirstName = "Mary";
upd.setFilter(filt);
upd.setFields({Email:"marysmith@address.com"});
upd.execute();
//Example #2: This example uses an object literal
//to update the Email field for records where
//the LastName field has the value "Smith"
//and the FirstName field has the value "Mary".
var upd = new cmdUpdate("AddressBook");
upd.setFilter({LastName:"Smith", FirstName:"Mary"});
upd.setFields({Email:"marysmith@address.com"});
upd.execute();
//Example #3: This example use a string to update
//the Email field for records where
//the LastName field has the value "Smith"
//and the FirstName field has the value "Mary".
var upd = new cmdUpdate("AddressBook");
upd.setFilter("FirstName = 'Mary' AND LastName = 'Smith'");
upd.setFields({Email:"marysmith@address.com"});
upd.execute();
Related
Topics
cmdUpdate Object,
cmdUpdate.getFilter(), cmdUpdate.execute()
|