Re: Batchupdates not working as expected



"pilmart" <martin.scullion@xxxxxxxxxxxxx> wrote in
news:4631f539$1@xxxxxxxxxxxxxxxxxxxxxx:


"Kevin Frevert" <kevin@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
"pilmart" <martin.scullion@xxxxxxxxxxxxx> wrote in message
news:4631e0f6$1@xxxxxxxxxxxxxxxxxxxxxxxxx

Am I correct in assuming I need to put the dataset into edit before
changing anything


Yes, before you can edit data inside a dataset, the dataset must be in
Edit mode (calling YourDataSet.Edit();) Same goes for inserting data
(must call the methods Insert or Append).

Good luck,
krf


OK here's what i'm doing I set the dataset properties cluseClient,
ctKeySet, ltBatchoptimistic, commandtext and open the data set.. all
OK so far, I put the dataset into edit, myds.edit, check to ensure
that the state is in dsedit, again all OK so far.

Start to walk the recordset with a while not eof loop and try to amend
a value in the dataset myds.fieldbyname('campaigncode').value := 44;
and lo and behold 'the dataset is not in edit or insert mode' ???, I
checked just before the loop and iwas in dsEdit any idea whats going
on here ???


See the help on the State property of TDataset: "The dataset state
constantly changes as an application processes data" and "Posting or
canceling edits, insertions, or deletions, changes State from its current
state to dsBrowse" and on the Next property "Next posts any changes to
the active record".

So before making changes to (fields in) a record, you should test the
State and, if necessary, call the Edit method.

HTH
.