Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with REPROCESS
Message
From
02/12/1998 13:46:47
 
 
To
02/12/1998 10:22:41
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00162993
Message ID:
00163313
Views:
31
>
>Look into your buffering schema and the LOCK() method. To see what it is trying to do. VFox will handle the record locking on its own if you let it. It is preferable to let the engine handle it rather than trying to force it.
>
>Regards,

Here is the updaterows() code for the save button of the TXTBTNS class.

It loops through ALL open tables that have table buffing enabled (which mine do), then it looks for each modified record, then locks that record, then updates it, then unlocks the row. This logic seems fine for my app.

Think about this...What happens if one users adds a blank record, and while he is typing in data into textboxes, another user adds another blank record, and while he is enering data into his textboxes, the first users does his save routine... won't the getnextmod() and tableupdate() funtions as used below do a save on ALL the newlwy appended records?


m.nModRecord = GetNextMod(0)
DO WHILE m.nModRecord # 0 &&loop locks all records
GO m.nModRecord
m.lSuccess = RLOCK() &&try to lock record
IF !m.lSuccess &&failed to lock record
m.cErrorMessage = E_RECORDLOCK_LOC
UNLOCK ALL
EXIT
ENDIF
IF !m.lHadMessage &&so we don't repeat alert
* See if record(s) modified by another user
FOR m.nFld = 1 TO FCOUNT()
IF TYPE(FIELD(m.nFld)) = "G" &&skip for General fields
LOOP
ENDIF
IF OLDVAL(FIELD(m.nFld)) # CURVAL(FIELD(m.nFld))
m.lHadMessage = .T.
IF MESSAGEBOX(E_DIRTYREC_LOC,4+48) = MSGBOX_YES
m.lOverwrite = .T.
ELSE
m.lSuccess = .F.
UNLOCK ALL
EXIT
ENDIF
ENDIF
ENDFOR
ENDIF
m.nModRecord = GetNextMod(m.nModRecord)
ENDDO
IF m.lSuccess &&was able to lock all records
m.lSuccess = TableUpdate(.T.,m.lOverwrite)
IF m.lSuccess &&was able to update all records
LOOP
ENDIF
UNLOCK ALL
ENDIF
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform