Board index » delphi » Detect if Updates Pending

Detect if Updates Pending

hello all,

I've a TADODataSet with the following properties set:
 - CursorLocation := clUseClient;
 - CursorType := ctStatic;
 - LockType := ltBatchOptimistic;

Now I can change one or more records and would like to know if there are
some updates pending before calling "UpdateBatch".
How can I do this?

Thanks

 

Re:Detect if Updates Pending


Hi,

I inherited from TADODataSet and created the following method:

function TSqADODataSet.GetUpdatesPending: Boolean;
var
  Populated: Boolean;
  CloneDataSet: TCustomADODataSet;
begin
   Populated := Active and not IsEmpty;
   Result := Populated and (Modified or (UpdateStatus <> usUnmodified));
   if (not Result) and Populated then
   begin
     CloneDataSet := TCustomADODataSet.Create(nil);
     try
       CloneDataSet.Clone(Self, LockType);
       CloneDataSet.Filtered := True;
       CloneDataSet.FilterGroup := fgPendingRecords;
       Result := not CloneDataSet.IsEmpty;
     finally
       CloneDataSet.Free;
     end;
   end;
end;

I hope have helped you,

Sanyo Moura.

Quote
"Reinhold Erlacher" <reinh...@logon.it> wrote in message

news:3bbb0fce$1_1@dnews...
Quote
> hello all,

> I've a TADODataSet with the following properties set:
>  - CursorLocation := clUseClient;
>  - CursorType := ctStatic;
>  - LockType := ltBatchOptimistic;

> Now I can change one or more records and would like to know if there are
> some updates pending before calling "UpdateBatch".
> How can I do this?

> Thanks

Re:Detect if Updates Pending


Why did you cloned and filtered the table?
the UpdateStatus and Modified property aren't enough? why?
I'm currently checking if a record is pending for update at the
OnBeforeScroll event.
If the current record has a RecordStatus different than rsUnmodified i make
updateBatch(arCurrent).
Is that ok? Will this raise other problems?

Re:Detect if Updates Pending


Quote
Emiliano Sosa <es...@gosierra.com> wrote in message news:3bbb4ccb_2@dnews...
> Why did you cloned and filtered the table?

because that way your original dataset keep it's current state...

Quote
> the UpdateStatus and Modified property aren't enough? why?

because UpdateStatus are only significant at record level (one record at a
time) and in Batchupdate you'll keep any number of modified, inserted or
deleted records unposted...

Quote
> I'm currently checking if a record is pending for update at the
> OnBeforeScroll event.
> If the current record has a RecordStatus different than rsUnmodified i
make
> updateBatch(arCurrent).
> Is that ok? Will this raise other problems?

Only performance problems (why batchupdate if you will post any changes
instantly?

Quote

Regards

Eduardo

Re:Detect if Updates Pending


Why need inherited a newclass,
you can just make a public function like
CheckUpdateState(ADOdataset:TADODataSet).

Henry He

Quote
"Sanyo Moura" <sa...@squadra.com.br> wrote in message

news:3bbb44b2_2@dnews...
Quote
> Hi,

> I inherited from TADODataSet and created the following method:

> function TSqADODataSet.GetUpdatesPending: Boolean;
> var
>   Populated: Boolean;
>   CloneDataSet: TCustomADODataSet;
> begin
>    Populated := Active and not IsEmpty;
>    Result := Populated and (Modified or (UpdateStatus <> usUnmodified));
>    if (not Result) and Populated then
>    begin
>      CloneDataSet := TCustomADODataSet.Create(nil);
>      try
>        CloneDataSet.Clone(Self, LockType);
>        CloneDataSet.Filtered := True;
>        CloneDataSet.FilterGroup := fgPendingRecords;
>        Result := not CloneDataSet.IsEmpty;
>      finally
>        CloneDataSet.Free;
>      end;
>    end;
> end;

> I hope have helped you,

> Sanyo Moura.

> "Reinhold Erlacher" <reinh...@logon.it> wrote in message
> news:3bbb0fce$1_1@dnews...
> > hello all,

> > I've a TADODataSet with the following properties set:
> >  - CursorLocation := clUseClient;
> >  - CursorType := ctStatic;
> >  - LockType := ltBatchOptimistic;

> > Now I can change one or more records and would like to know if there are
> > some updates pending before calling "UpdateBatch".
> > How can I do this?

> > Thanks

Re:Detect if Updates Pending


Of course, but since I have other implementations, I prefer to inherit a new
class.

Sanyo.

Quote
"Henry He" <hexing...@163.net> wrote in message news:3bc0aaf0_2@dnews...
> Why need inherited a newclass,
> you can just make a public function like
> CheckUpdateState(ADOdataset:TADODataSet).

> Henry He

> "Sanyo Moura" <sa...@squadra.com.br> wrote in message
> news:3bbb44b2_2@dnews...
> > Hi,

> > I inherited from TADODataSet and created the following method:

> > function TSqADODataSet.GetUpdatesPending: Boolean;
> > var
> >   Populated: Boolean;
> >   CloneDataSet: TCustomADODataSet;
> > begin
> >    Populated := Active and not IsEmpty;
> >    Result := Populated and (Modified or (UpdateStatus <> usUnmodified));
> >    if (not Result) and Populated then
> >    begin
> >      CloneDataSet := TCustomADODataSet.Create(nil);
> >      try
> >        CloneDataSet.Clone(Self, LockType);
> >        CloneDataSet.Filtered := True;
> >        CloneDataSet.FilterGroup := fgPendingRecords;
> >        Result := not CloneDataSet.IsEmpty;
> >      finally
> >        CloneDataSet.Free;
> >      end;
> >    end;
> > end;

> > I hope have helped you,

> > Sanyo Moura.

> > "Reinhold Erlacher" <reinh...@logon.it> wrote in message
> > news:3bbb0fce$1_1@dnews...
> > > hello all,

> > > I've a TADODataSet with the following properties set:
> > >  - CursorLocation := clUseClient;
> > >  - CursorType := ctStatic;
> > >  - LockType := ltBatchOptimistic;

> > > Now I can change one or more records and would like to know if there
are
> > > some updates pending before calling "UpdateBatch".
> > > How can I do this?

> > > Thanks

Other Threads