Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
'Record in use' error...
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00147351
Message ID:
00147416
Views:
31
>I had the same problem On Win NT 4. You have to lock the Table header before doing an insert. Becasue when you do an insert VFP tries to lock the header.
>
>Check to see if you have access. If so Lock the header then use the insert coimmand.
>
>I've got a Function Called Headlock
>
>Can use this function in a loop or use a timer event.
>
>IF RLOCK("0",alias())
> RETU(.T.)
>ENDIF
>
>EG.
>
>IF Headlock("MyAlias")
> Insert Into MyAlias
> Unlock
>Endif

EG's correct, but I'd expand the lock function to look like this, put it in a procedure file or your goApp and call it with the parameter of the file:

=Headlock("myAlias")
Insert...
UNLOCK

PROCEDURE HeadLock
LPARAMETER cfile

IF FLOCK(m.cfile)
RETURN
ENDIF
WAIT WINDOW NOWAIT NOCLEAR "Attempting to lock " +m.cfile +"...please wait."
DO WHILE ! FLOCK(m.file)
ENDDO
WAIT CLEAR

I also use a LockRec procdure similar to the above to lock a record before updating changes. I've found that by contolling the locking and unlocking manually elimiates conflicts.
Ken Sorce
Team RAD, Inc.
Rapid Application Developers
Ken@TeamRAD.com
www.teamrad.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform