David,
> At update
>
> if oSavedRecord == oDbfDataSet1:GetRecord()
> oDbfDataSet1:Update()
> else
> MsgInfo( "Record was updated by another user, changes aborted !")
> oDbfDataSet1:Cancel()
> endif
>
>
> Any comment on the above routine ?
It will not work. You can not compare the two objects that way. That
comparition only tells if boh are exactly the same object, which is always
not true in your case. Yo should compare all its members:
FUNCTION RecordsEqual( oRec1, oRec2 )
Local nFor
Local aValues1, aValues2
aValues1 := oRec1:GetValues()
aValues2 := oRec2:GetValues()
FOR nFor := 1 TO Len( aValues1 )
IF aValues1[ nFor ] != aValues2[ nFor ]
RETURN .F.
ENDIF
NEXT
RETURN .T.
--
Ignacio Ortiz de Zúñiga
http://www.xailer.com
"david fung" <
davfung@yahoo.com> escribió en el mensaje
news:[email=
451b8e2a@news.xailer.com...]
451b8e2a@news.xailer.com...[/email]
> david fung wrote:
>> Ignacio Ortiz de Zúñiga wrote:
>>> David,
>>>
>>> 1. I wonder why the content (a "Calcfield" )of the oDBBrowse displayed
>>>> in the captured fashion ? Is there a way to correct it ?
>>>
>>> Is just a bug on the demo that is already fixed. Just change the
>>> following:
>>>
>>> STATIC FUNCTION FirstLast( oDataField )
>>>
>>> LOCAL cText
>>>
>>> WITH OBJECT oDataField:oDataSet
>>> cText := Trim( :First( dsFIELD ) ) + " " + Trim( :Last(
>>> dsFIELD ) )
>>> END WITH
>>>
>>> RETURN cText
>>>
>>>> 2. When I start two instants of this application and attempt to update
>>>> the same record, there seem to have no check in the content of the
>>>> record prior to the update(). The 2nd update will wipe out all changes
>>>> from the 1st update. attempt to use oDbfDataSet1:Reclock(), but it does
>>>> not check the content of the record. What should be the proper way to
>>>> implement a Rlock() ? savetoarray.. ?
>>>
>>> You can lock the record with oDataset:Edit( .T. ) or save its content
>>> with oDataSet:GetRecord() and check if something has changed before
>>> doing the Update().
>>>
>>> Regards,
>>
>
>
> What is the proper way to save up an record ?
>
> oSavedRecord := oDbfDataSet1:GetRecord() ?
>
>
> At update
>
> if oSavedRecord == oDbfDataSet1:GetRecord()
> oDbfDataSet1:Update()
> else
> MsgInfo( "Record was updated by another user, changes aborted !")
> oDbfDataSet1:Cancel()
> endif
>
>
> Any comment on the above routine ?