Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

locking one record -possible?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi!
I'm very confused about, how to resolve this problem!

Need to update one selected record from a recordset. The scenario is the following: after selecting the desired record, appears a form with all the fields holding their actual values.(input type=text), and a submit button. After changes are made, (submit) I have an update command,which updates all the fields from that record whith the new values. Everything is OK, unless when 2 users simultaneosly updates the same record, the result will be (logic) the data from the user who clicked the submit button later then the other. And this is not very correct, for example if the first user modified a single field (A), the second modified an other field (B), the first modification (field A) will be lost.
How can I resolve this problem, by locking the record?
Or by modifying only one field in a form?
I don't know very much about locking, please give me some clues!?
 
There are several differant formats for updating a record depending on whether you are using SQL or opening a table, etc
If you display your code we will be able to help you more specifically.
In this case it shouldn't be losing the value unless your writing all the values to the update, whether or not they have been changed. What I generally do in a situation like this is only write the values that have changed. One way of accomplishing this is to display the record in text on your form page with empty entries if they wish to change it. This way you can only update the fields that have information in them. If you are using SQL than you do if checks to add portions of the update string if the Request.Form(&quot;txtWhatever&quot;) <> &quot;&quot;, if you are using the objRS.Update method than you can use the same if statement to decide if you are going to set objRS(&quot;whatever&quot;) in the db before your .Update command.

The only issue you will have with this is if the users decide to update the same field in the same record.
-Tarwn
------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
Thanks for your advice, it's a good tip!
I'm using SQL for update. The problem is that the users must see the inital values on the form, so I think I can type them in the left side of the text box, and leave the text boxes empty.
Only for curiosity: can I lock manualy some records in ASP, a read some FAQ's about cursor types, pessimistic, optimistic locking, but I think, I can't use this in my case.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top