Board index » delphi » ADO briefcase model repeat call for help

ADO briefcase model repeat call for help

I am using ADO under D6 to implement a "briefcase" model of my simple
database. When connected to the network, the server is used as the source of
the data and an option allows you to "go offline" where it uses the
savetofile ability of the ADO Dataset. When the application is started it
checks if an "off line" dataset is available and uses that allowing you to
add, delete and modify records and save the change log along with the data
back to disk. When you are connected to a server, the Change log can be
applied to the server using the updatebatch method of the ADO dataset. All
pretty standard stuff.

Now, insertions, deletions and modifications work when there is only one
"off line" dataset. If I have two (perhaps on two separate machines) I need
to "merge" the two change logs. BDE handles conflicts quite nicely, checking
for conflicts (updateing a row deleted by the other change log, for example)
and generating an OnUpdateError event. The question is....

How do you do this in ADO? I cannot find an OnReconcileError method! Do I
have to go through each record checking its status and  handling them
individually? How do other people handle this.

Many thanks for help and pointers to help or examples

Stuart

 

Re:ADO briefcase model repeat call for help


Oooopppss, forget the link problem-You even said watch the word wrap. Put it
down to a VERY long day!

Last little problem, where are the constants adAffectGroup,
adResyncUnderlyingValues declared? (Delphi 6)

Once again, many thanks. I'll read the link carefully

Stuart

Quote
"Andy Mackie" <_@_> wrote in message

news:3dc91c8d$3@newsgroups.borland.com...
Quote
> "Stuart Cox" <stu...@auditmaster.co.uk> wrote in message
> news:3dc90ee6$1@newsgroups.borland.com...
> > How do you do this in ADO? I cannot find an OnReconcileError method!

> After calling UpdateBatch, set the FilterGroup to be fgConflictingRecords,
> then set Filtered = true, to
> find out what records couldn't be updated. You can also retrieve the
> underlying values in the database to see what the conflicts are between
the
> data you are trying to update and what actually exists in the database.
> e.g. adoDataSet1.Recordset.Resync(adAffectGroup,

adResyncUnderlyingValues);
Quote

> You can then use TField's NewValue, CurValue and OldValue to see what the
> problem is.

> OldValue - the OriginalValue in ADO, holds the original value read from
the
> database
> CurValue  - the UnderlyingValue in ADO, containing the conflicting value
> from the database (e.g. entered by another user)
> NewValue - the new value entered by the user.

> For more info on resolving conflicts see:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado2...
Quote
> mdcondetectresolveconflicts.asp

>  (watch for word wrap)

> Regards,
> Andy Mackie.

Re:ADO briefcase model repeat call for help


I have had a play with the mechanisms you describe and they work well!

The small problem I now have is with deleted records. I have looked at the
MSDN articles but cant find anything to help, there is a bit of help with
the filter group fgpredictive but that dosn't seem to work quite the way I
expect. I need to be able to identify records that have subsequently been
deleted in the underlying data and perhaps modified in the Update. I also
need to do the reverse, establish which records have been deleted in the
update but modified in the underlying dataset after the copy was taken.

If you think this should be taken off-line, please feel free to email me
direct.

Once again, thanks for your help

Stuart

Quote
"Andy Mackie" <_@_> wrote in message

news:3dc91c8d$3@newsgroups.borland.com...
Quote
> "Stuart Cox" <stu...@auditmaster.co.uk> wrote in message
> news:3dc90ee6$1@newsgroups.borland.com...
> > How do you do this in ADO? I cannot find an OnReconcileError method!

> After calling UpdateBatch, set the FilterGroup to be fgConflictingRecords,
> then set Filtered = true, to
> find out what records couldn't be updated. You can also retrieve the
> underlying values in the database to see what the conflicts are between
the
> data you are trying to update and what actually exists in the database.
> e.g. adoDataSet1.Recordset.Resync(adAffectGroup,

adResyncUnderlyingValues);
Quote

> You can then use TField's NewValue, CurValue and OldValue to see what the
> problem is.

> OldValue - the OriginalValue in ADO, holds the original value read from
the
> database
> CurValue  - the UnderlyingValue in ADO, containing the conflicting value
> from the database (e.g. entered by another user)
> NewValue - the new value entered by the user.

> For more info on resolving conflicts see:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado2...
Quote
> mdcondetectresolveconflicts.asp

>  (watch for word wrap)

> Regards,
> Andy Mackie.

Re:ADO briefcase model repeat call for help


"Stuart Cox" wrote

Quote
> I have had a play with the mechanisms you describe and they work well!
> The small problem I now have is with deleted records.

Some possibilites:
Examining the CurValue (UnderlyingValue in ADO) will give an exception if
the record was deleted in the database.
Examine the RecordStatus and UpdateStatus of the ADODataSet
Examine the Status property of the RecordSet
Alternatively, calling Resync will give an exception if the row can't be
located.

I haven't really explored this, so can't comment on the best approach. Try
the microsoft.public.data.ado newsgroup and you might get some answers.
Chapter 12 in the Programming ADO book by David Sceppa discusses detecting
and handling conflicts. You might want to get a copy of that.
http://www.amazon.com/exec/obidos/ASIN/0735607648/

Sample chapters at:
http://www.microsoft.com/mspress/books/sampchap/3445.asp

The ADO constants are defined in ADOInt.pas.

Regards,
Andy Mackie.

Other Threads