473,809 Members | 2,819 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1258
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.

"jasonkeste r" 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
4016
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 fieldX=valueX WHERE id IN (SELECT tX.id FROM tableX AS tX WHERE tX.fieldY=valueY AND filedZ=valueZ);
8
8618
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 the primary exchange for that symbol. Each symbol can only have one primary exchange. I am trying to write a insert/update/delete trigger that enforces this rule. The rules I have thought of are as follows: Insert If new row has flag...
1
6454
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 "problem" with triggers is that they generate lots of extra SQL-code I would like a solution something like below. If there are any
17
5033
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 cust_no, ded_type_cd, chk_no)
16
17026
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 must be UPDATED, if not, they must be INSERTED. Logically then, I would like to SELECT * FROM <TABLE> WHERE ....<Values entered here>, and then IF FOUND UPDATE <TABLE> SET .... <Values entered here> ELSE INSERT INTO <TABLE> VALUES <Values...
16
3881
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 table, or perhaps bytes, being updated where the engine just decides, screw it, i'll just make a new one. surfed this group and google, but couldn't find anything. the context: we have some java folk who like to parametize/
25
4079
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
1
2317
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 - Date/Time TimeOpened - Date/Time
7
9785
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 I've got stuck trying to write a DELETE statement. Here's the table I'm working on: CREATE TABLE `articles_categories` (
0
9601
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10635
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10378
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10115
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9198
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7653
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.