 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
pilmart Guest
|
Posted: Fri Apr 27, 2007 3:31 pm Post subject: Batchupdates not working as expected |
|
|
HI There
Just started playing with batch updates in ADO, have set up a TADODataset with clUseClient, ltBatchoptimistic, ctKeyset an appropriate connection and SQL statement. The dataset opens up OK
but when I attempt to change a value I get 'dataset not in edit of insert mode'
None of the examples seem to indicate placing the dataset into 'edit' mode, however if I do this by 'myDS.edit' it all works any suggestions ???? |
|
| Back to top |
|
 |
Chris.Cheney Guest
|
Posted: Fri Apr 27, 2007 4:14 pm Post subject: Re: Batchupdates not working as expected |
|
|
"pilmart" <martin.scullion (AT) capgemini (DOT) com> wrote in
news:4631d112$1 (AT) newsgroups (DOT) borland.com:
| Quote: |
HI There
Just started playing with batch updates in ADO, have set up a
TADODataset with clUseClient, ltBatchoptimistic, ctKeyset an
appropriate connection and SQL statement. The dataset opens up OK but
when I attempt to change a value I get 'dataset not in edit of insert
mode'
None of the examples seem to indicate placing the dataset into 'edit'
mode, however if I do this by 'myDS.edit' it all works any suggestions
????
|
See the Delphi help topics "Understanding datasets" and "Modifying data".
TADODataset descends from TDataset where the Edit method is defined.
BTW I wonder which examples you are referring to. |
|
| Back to top |
|
 |
pilmart Guest
|
Posted: Fri Apr 27, 2007 4:39 pm Post subject: Re: Batchupdates not working as expected |
|
|
"Chris.Cheney" <Chris.CheneyXXNOSPAMXX (AT) tesco (DOT) net> wrote:
| Quote: | "pilmart" <martin.scullion (AT) capgemini (DOT) com> wrote in
news:4631d112$1 (AT) newsgroups (DOT) borland.com:
HI There
Just started playing with batch updates in ADO, have set up a
TADODataset with clUseClient, ltBatchoptimistic, ctKeyset an
appropriate connection and SQL statement. The dataset opens up OK but
when I attempt to change a value I get 'dataset not in edit of insert
mode'
None of the examples seem to indicate placing the dataset into 'edit'
mode, however if I do this by 'myDS.edit' it all works any suggestions
????
See the Delphi help topics "Understanding datasets" and "Modifying data".
TADODataset descends from TDataset where the Edit method is defined.
BTW I wonder which examples you are referring to.
|
OK then I suppose I do need to put it into edit state btw the examples I have been reading come from the 'Opening the dataset in batch update mode' example in Using batch updates, there does not appear to be any mention of using dataset.edit in any of these examples hence my confusion.
Am I correct in assuming I need to put the dataset into edit before changing anything |
|
| Back to top |
|
 |
Kevin Frevert Guest
|
Posted: Fri Apr 27, 2007 5:08 pm Post subject: Re: Batchupdates not working as expected |
|
|
"pilmart" <martin.scullion (AT) capgemini (DOT) com> wrote in message
news:4631e0f6$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
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 |
|
| Back to top |
|
 |
pilmart Guest
|
Posted: Fri Apr 27, 2007 6:06 pm Post subject: Re: Batchupdates not working as expected |
|
|
"Kevin Frevert" <kevin (AT) workdrinkingicewater (DOT) com> wrote:
| Quote: | "pilmart" <martin.scullion (AT) capgemini (DOT) com> wrote in message
news:4631e0f6$1 (AT) newsgroups (DOT) borland.com...
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 ??? |
|
| Back to top |
|
 |
yannis Guest
|
Posted: Fri Apr 27, 2007 6:17 pm Post subject: Re: Batchupdates not working as expected |
|
|
pilmart has brought this to us :
| Quote: | "Kevin Frevert" <kevin (AT) workdrinkingicewater (DOT) com> wrote:
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 ???
|
When you are using myds.edit you do not set the entire dataset in to
edit mode just the focused record. The moment you change the focused
record the dataset is posting the changes you have made and then
continues to the record you have selected. You need to set the dataset
in edit mode after you have found the record you want to edit and after
finished editing the record you need to call the post method. Now when
you call myds.post the validation of the data enter happens if there is
any problem with the new data an exception is raised which gives you
the oportunity to react on this error.
Regards
Yannis. |
|
| Back to top |
|
 |
yannis Guest
|
Posted: Fri Apr 27, 2007 6:22 pm Post subject: Re: Batchupdates not working as expected |
|
|
on 27/04/2007, yannis supposed :
Sorry I must mention also that if the DS is in batch mode no changes
are posted back to the server until you call myds.UpdateBatch either
wise after each post the data are send to the server.
Regards
Yannis. |
|
| Back to top |
|
 |
Chris.Cheney Guest
|
Posted: Fri Apr 27, 2007 6:31 pm Post subject: Re: Batchupdates not working as expected |
|
|
"pilmart" <martin.scullion (AT) capgemini (DOT) com> wrote in
news:4631f539$1 (AT) newsgroups (DOT) borland.com:
| Quote: |
"Kevin Frevert" <kevin (AT) workdrinkingicewater (DOT) com> wrote:
"pilmart" <martin.scullion (AT) capgemini (DOT) com> wrote in message
news:4631e0f6$1 (AT) newsgroups (DOT) borland.com...
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 |
|
| Back to top |
|
 |
pilmart Guest
|
Posted: Fri Apr 27, 2007 6:51 pm Post subject: Re: Batchupdates not working as expected |
|
|
"Chris.Cheney" <Chris.CheneyXXNOSPAMXX (AT) tesco (DOT) net> wrote:
| Quote: | "pilmart" <martin.scullion (AT) capgemini (DOT) com> wrote in
news:4631f539$1 (AT) newsgroups (DOT) borland.com:
"Kevin Frevert" <kevin (AT) workdrinkingicewater (DOT) com> wrote:
"pilmart" <martin.scullion (AT) capgemini (DOT) com> wrote in message
news:4631e0f6$1 (AT) newsgroups (DOT) borland.com...
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
|
Thanks folks have got it now, I was under the impression that you only needed to put the dataset into edit once not for each record hence my confusion when the edit state disappeared after moving to next record, once agin thanks for your help |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|