I'm super new at coding and I'm making a simple apps now.
So as you can see in the pic, I have multiple data in selected date. If I wanted to update every row with different values and do it with save button, what code should I do?
Does my dbgrid need more setting at its properties?
I'm using Delphi 7 and zeos as db connection as well as oracle as db. Thanks in advance.
There are different ways depends of what you want and what you use.
If you wish to edit several rows into DBGrid and save them simultaneously, most dataset components supports a
CachedUpdate
mode (look into the Zeos documentation for details). In this mode dataset holds all changes made until you callApplyUpdates
method to put these changes into DB using one batch.Using Oracle, you can do it without cached updates, just use 'long transaction'. In this case you should start transaction when form opens, edit and post data at usual way and commit them when
Save
pressed. This way have some disadvantages, but I doubt you'll face them.If you wish to do some sort of mass update when pressing
Save
button, you have two ways. First of all, you can set up a query component, set it's SQL property into something likeand call it into save action handler:
Otherwise, you can do it from client:
That's, generally, not so good way, so don't addict of that.