Business Logic Framework - How To:
Updating multiple records of a single table at a time is very simple task with Quick Objects. The process is similar to specifying a search criteria for Find method and specifying what needs to be saved during an Update method. Once the search criteria is specified and the values that need to be updated are set it is as simple as calling the BulkUpdate method. The BulkUpdate method returns a bool if there were any records updated. A false return doesn't not mean that there were any errors, to check for errors please use the ErrorString property. After the BulkUpdate method has executed, you can use the AffectedRecords property to get a total number of rows updated by the statement.
![]() |
Note: We recommend that you use caution while using BulkUpdate and BulkDelete methods as they can modify/delete many records at a time, and if wrong criteria is specified by mistake the result can be disastrous. |
The target of the following code is to update all the UserRoles records where the RoleName value is "Client". Since the RoleName column is in the Roles table, we will create a join between UserRoles and Roles objects and set the UseInSave and UseInSearch properties of the appropriate fields that we would like to include in our search criteria and the ones that need to be updated.
| using (UserRoles ur = new UserRoles()) | |
| { | |
| ur.Join_RoleID_Roles_Parent(); | |
| // We can specify search criteria on joined objects. | |
| // In the following two lines we will assign the value "Client" to the RoleName and also set RoleName's UseInSearch property to true. | |
| ur.RoleID_Roles_Parent.RoleName.Value = "Client"; | |
| ur.RoleID_Roles_Parent.RoleName.UseInSearch = true; | |
| // Our target is to set the IsActive to true (and 'Y' for Oracle) so we set the IsActive value to true, and set the IsActive's UseInSave property to true as well. | |
| ur.IsActive.Value = true; | |
| ur.IsActive.UseInSave = true; | |
| // BulkUpdate method uses the search criteria and creates an update statement capable of updating 0-n records based on your criteria and available records in the database. | |
| // If there is an error during the update process the method will return false. | |
| if (ur.BulkUpdate()) | |
| { | |
| MessageBox.Show(ur.AffectedRecords.ToString() + " records updated"); | |
| } | |
| else | |
| { | |
| MessageBox.Show("Records could not be updated. Error: " + ur.ErrorString); | |
| } | |
| } | |
| Using ur As UserRoles = New UserRoles() | |
| ur.Join_RoleID_Roles_Parent() | |
| 'We can specify search criteria on joined objects. | |
| 'In the following two lines we will assign the value "Client" to the RoleName and also set RoleName's UseInSearch property to true. | |
| ur.RoleID_Roles_Parent.RoleName.Value = "Client" | |
| ur.RoleID_Roles_Parent.RoleName.UseInSearch = True | |
| 'Our target is to set the IsActive to true (and 'Y' for Oracle) so we set the IsActive value to true, and set the IsActive's UseInSave property to true as well. | |
| ur.IsActive.Value = True | |
| ur.IsActive.UseInSave = True | |
| 'BulkUpdate method uses the search criteria and creates an update statement capable of updating 0-n records based on your criteria and available records in the database. | |
| 'If there is an error during the update process the method will return false. | |
| If ur.BulkUpdate() Then | |
| MessageBox.Show(ur.AffectedRecords.ToString() & " records updated") | |
| Else | |
| MessageBox.Show("Records could not be updated. Error: " & ur.ErrorString) | |
| End If | |
| End Using | |
See Also:

