79202175

Date: 2024-11-19 05:33:34
Score: 1
Natty:
Report link

Most of the time I try to handle this with a submit button where it takes the values of the checkboxes and does everything you want them to do at once. As you have it, it looks like it's doing 2 seperate DB queries (not concurrent) everytime the user checks/unchecks the box. Sometimes I can see where that would be required but if it isn't, then see if you can find a way to simplify the process.

Either way, I think you probably want to look into creating a 'Stored Procedure' in the DB and utilize a 'Transaction' which is similar to a Try/Catch in that it can be made to execute all of the queries in a single transaction or none at all if it encounters an error. There are a lot of other things that can be done with Transactions (i.e. rollback, continue, etc) but that's another topic entirely.

For your purposes, try a Transaction within a Stored Procedure. It should accomplish what you're trying to do.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Kevin