Board index » delphi » Delayed posting with ADO dataset and DBGrid

Delayed posting with ADO dataset and DBGrid

I have a project set up in the following manner:

A global datastore holds a TADOConnection object, that is used by all forms
to access the underlying database.

A particular form has a TADODataset object that uses the global
TADOConnection.
A datasource is connected to the TADODataset to provide access.
A DBGrid is connected to the datasource.

My question is how can I delay modifications to the dataset made in the
DBGrid from being posted instantly after the edit?  Since I'm sharing the
TADOConnection between many screens, I would like to be able to post edits
to a screen all at once when the user hits 'save' or closes the form.  At
that point I would open a transaction in the TADOConnection using
BeginTrans, then post the edits, and do a CommitTrans to finish.  If an
error ocurred, i could use RollbackTrans to undo the edits made by the user
in the screen.  Or, if the user hits 'cancel' I would not do any transaction
processing for the edits to the dataset.

I cannot use BeginTrans when the screen is first open, because it is
possible for the user to switch to another screen that may make use of the
TADOConnection, which would in itself attempt to use the current transaction
and most likely issue a commit before the other screen is finished, which
would effectively rule out a rollback by the first transaction.

Is this possible?  Anybody have a workaround??

Chris

 

Re:Delayed posting with ADO dataset and DBGrid


Quote
>I cannot use BeginTrans when the screen is first open, because it is
>possible for the user to switch to another screen that may make use of the
>TADOConnection, which would in itself attempt to use the current transaction
>and most likely issue a commit before the other screen is finished, which
>would effectively rule out a rollback by the first transaction.

ADO has a batch update mode.  See the UpdateBatch method
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads