Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Add-Edit-Delete, best way
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00052551
Message ID:
00052914
Views:
42
>>>Like to have some advise on the best way to handle table maintenance
>>>in a Network environment.
>>>1) Having the ControlSource assigned to each field, when doing a ADD
>>> with APPEND BLANK 'might??' cause problem if another user activated
>>> the same(ADD function) in a network.
>>>2) Is it good to use record buffering? Pessimistic or Optimistic?
>>>3) Is record locking handled automatically by VFP 3.0 when
>>> APPEND BLANK and REPLACE commands is issued.
>>> If so, when will it be released(unlocked record)?
>>>
>>>Pls advise (I'm quite confused on finding the best way to handle).
>>>Cheers
>>>
>
>>
>>I prefer (when adding a record) to use an entry form where all data
>fields
>>are empty. When user 'accepts' or hits a 'save' button, I execute code
>to
>>generate a primary key for the new record, put all the date fields into
>an
>>array, then do a SQL - INSERT. This prevents problem of primary key
>>violations, blank records, still allows other users to be editing
>current
>>records during the 'add record' process, etc. VFP handles the automatic
>>locking then unlocks the table header.
>>
>>Insert into MyTable from array MyArray
>>
>>I also prefer optimistic row buffering and do a tableupdate() or
>>tablerevert() on that row only depending on how the user 'exited' that
>row
>>or form. I avoid table locking as much as possible because this
>prevents
>>other users from editing individual records at the same time.
>
>What is the differences/advantages in using INSERT and REPLACE
>commands?

Alvin,

I also use Mark's manner to do the adds as INSERT-SQL is the best way to put a record in a table. I usually use optimistic buffering but am now writing an app that is using pessimistic (client's request). All of my forms handle each of the modes - Add, Edit and Delete. My form template (base class form) has two placeholder methods - SetControls() and RemoveControls(). When a user clicks the New button, the RemoveControls() method removes the .ControlSource property from all the entry fields. My Save button understands that when it's in Add mode, it does an Insert-SQL. If the user clicks the Find button and by whatever method you give to users to select a record for editing or deleting, the form fires the .SetControls() method where the .ControlSource property is set for all the entry fields. The Save button, whether it has just inserted a new record or if the user is editing or deleting, sets off a transaction manager which performs the =tableupdate() within the confines of a transaction.

Steve Despres
Previous
Reply
Map
View

Click here to load this message in the networking platform