Jailendra K
MIS
Dear sir,
I am opening a grid using cursorsetprop("Buffering",5) in one PC and open the same table in another grid in another PC. Whenever i save the data changes with tableupdate in PC2 and after that edit the data in PC1, TABLEUPDATE(.T.,.F.) does'nt detect conflict and always return .T.., why? As soon as i edit data grid in PC2 it appears in data grid in PC1 thats why OLDVAL and CURVAL become same and tableupdate return .T.. Anyone please resolve my issue.
My codes are placed in a form as mentioned below:
In Load Pro................
I am opening a grid using cursorsetprop("Buffering",5) in one PC and open the same table in another grid in another PC. Whenever i save the data changes with tableupdate in PC2 and after that edit the data in PC1, TABLEUPDATE(.T.,.F.) does'nt detect conflict and always return .T.., why? As soon as i edit data grid in PC2 it appears in data grid in PC1 thats why OLDVAL and CURVAL become same and tableupdate return .T.. Anyone please resolve my issue.
My codes are placed in a form as mentioned below:
In Load Pro................
Code:
CLOSE all
CLEAR
set exclusive off
SET MULTILOCKS ON
sele a
use \\jai\milk\mytable shared
&& Allow optimistic table buffering
p=CURSORSETPROP("Buffering",5) && Optimistic table buffering on
In Save Command button:-----------
BEGIN TRANSACTION
iSuccess=TABLEUPDATE(.T.,.F.) && Commit changes made to table
*? "Table changes committed"
ncurRec=0
if iSuccess=.F.
ROLLBACK
AERROR(aErrors)
if aErrors[1,1]=1585
ncurRec=getnextmodified(ncurRec)
do while ncurRec<>0
go ncurRec
RLOCK()
for nField= 1 to FCOUNT()
cField=FIELD(nField)
if OLDVAL(cField)<>CURVAL(cField)
nResult=MESSAGEBOX("Record has been changed. Save?",4+48+0,"Data Changed")
if nResult=7
TABLEREVERT(.F.)
UNLOCK RECORD nCurRec
ENDIF
EXIT
ENDIF
ENDFOR
ncurRec=getnextmodified(ncurRec)
ENDDO
BEGIN TRANSACTION
TABLEUPDATE(.T.,.T.)
END TRANSACTION
ENDIF
ELSE
END TRANSACTION
ENDIF
use
CLOSE ALL
thisform.refresh
thisform.release