473,408 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Retreive, Update, Delete problem....

Hi All,
I have question regarding to the read, and update the row in the table.

for example:
user A, read the row of data from the table.
user B, read the row of data from the table as well.
user A, update the row of data. (lock)
user B, update the row of data. (fail due to user A lock)
user A, release the lock. (unlock)
At the user B side, the data auto refresh in the data grid table.
This time, user B update the row of data (lock).
Lastly, user B unlock the row of data. (unlock).

My question is:
how to implement this in the web form.
Any additional setting is needed in sql server 2000?
What is the additional code is needed to the coding page?
What is the additional T-SQL language is needed in our query? "? Insert..?
Select.. ? Update..? Delete..".

Any ideas? Any guidelines?
Your help will be appreciated.

Thank you in advance.

Best regards,
Daniel.
Nov 19 '05 #1
4 1233
If you know you are going to modify and save a record after reading it,
you should pull it up inside the same transaction as your Update, and
use WITH (UPDLOCK) on the Select to hold the lock until you perform
your Update.

so,

(A) begin transaction A
(A) select row WITH (UPDLOCK)
(B) begin transaction B
(B) select row // will block...
(A) update row
(A) commit transaction A
(B) // finally receive row requested above because transaction A no
longer blocks.
Hope this helps!

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

Nov 19 '05 #2
Hi jason,
If use UPDLOCK, what is the unlock command for it?
If the user B is trying to view the row of record which is updating by user
A, what the user B can display? Is it empty record in the data grid table or
still allow to view but not the update access?

Please guide me thru..thank you.

"jasonkester" wrote:
If you know you are going to modify and save a record after reading it,
you should pull it up inside the same transaction as your Update, and
use WITH (UPDLOCK) on the Select to hold the lock until you perform
your Update.

so,

(A) begin transaction A
(A) select row WITH (UPDLOCK)
(B) begin transaction B
(B) select row // will block...
(A) update row
(A) commit transaction A
(B) // finally receive row requested above because transaction A no
longer blocks.
Hope this helps!

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

Nov 19 '05 #3
You can dig around in the SQL documentation for a walkthru, but
basically any records that you Select WITH (UPDLOCK) inside of a
Transaction will be unavailable to any other Select statement that also
uses WITH (UPDLOCK) until you either Commit or Rollback the
Transaction.

The easiest way to watch this in action is inside Query analyzer. Open
a new connection, paste the following code and run it (substituting a
table and recordID from your database):

begin transaction
select *
from Location WITH (UPDLOCK)
where LocationID = 10

Next open another query window, paste the same query and run it too.
It should just sit there, not returning anything.
Next, go back to the first query window and add the following line,
then select it and hit F5:

commit transaction

If you look at window #2, you will see that it has stopped blocking,
and has returned a record.

In your application, you'll use the SqlTransaction object in ADO.NET
rather than the BEGIN & COMMIT statements above.

Good luck!

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

Nov 19 '05 #4
thank you Jason..

"Daniel" wrote:
Hi All,
I have question regarding to the read, and update the row in the table.

for example:
user A, read the row of data from the table.
user B, read the row of data from the table as well.
user A, update the row of data. (lock)
user B, update the row of data. (fail due to user A lock)
user A, release the lock. (unlock)
At the user B side, the data auto refresh in the data grid table.
This time, user B update the row of data (lock).
Lastly, user B unlock the row of data. (unlock).

My question is:
how to implement this in the web form.
Any additional setting is needed in sql server 2000?
What is the additional code is needed to the coding page?
What is the additional T-SQL language is needed in our query? "? Insert..?
Select.. ? Update..? Delete..".

Any ideas? Any guidelines?
Your help will be appreciated.

Thank you in advance.

Best regards,
Daniel.

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: red85 | last post by:
hello i have mysql 4.1 with win2000 SP3, i know that it is only an alpha and i don't know if someone else has already posted this problem: when i execute this sql UPDATE tableX SET...
8
by: Jason | last post by:
I have a table that matches up Securities and Exchanges. Individual securities can belong on multiple exchanges. One of the columns, named PrimaryExchangeFlag, indicates if a particular exchange is...
1
by: Jon | last post by:
Hi all! Are there any other way than using rights or Triggers to prevent a DELETE or an UPDATE on a specific column. The "problem" with rights is that they dont apply to all DB-users The...
17
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
25
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
1
by: mivey4 | last post by:
Okay, The problem is that I have an Access Database that has the following fields: EmpID - Autonumber (PrimaryKey) AccountID - Text IssueReported - Memo DateOpened ...
7
by: Jon Maz | last post by:
Hi, I have a MySql problem I hope someone can help me with. I'm trying to run an update on a linking table, the update is running into a Primary Key constraint violation, and in my workaround...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.