Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I can't remember the syntax it's like Begin Transaction and End Transaction or lock and unlock. It only allows one user thread to enter the code block. Can anyone help me remembering it.

Thanks in advance!
Posted
Updated 20-Jun-11 4:47am
v2
Comments
Manfred Rudolf Bihy 20-Jun-11 10:51am    
Edit: Clarified user vs. threading issue.

For ASP.Net? I don't believe it is possible to write a single-user web site.
 
Share this answer
 
Comments
JustWorking 20-Jun-11 9:37am    
Yes we can but I do't think you understand my question. Its like when adding a new ID but you don't want 2 have same ID so you add this code its like lock and unlock or something like that.
Gregory Gadow 20-Jun-11 9:45am    
So your question is about SQL and database management, not ASP.Net. You may want to change the tags on your question, then: you will likely get a more meaningful response when people know what you are asking about.
JustWorking 20-Jun-11 9:47am    
No I'm talking about a code inside ASP.NEt
You can use the lock syntax to provide thread syncronisation

http://msdn.microsoft.com/en-us/library/c5kehkcz.aspx[^]

That's to do with threading, rather than 'user' actions though.

For your comment on Gregory.Gadow's answer, if you wanted an ID to be unique you'd certainly leave that to an underlying database operation (an Identity field) to allocate.
 
Share this answer
 
Comments
Manfred Rudolf Bihy 20-Jun-11 10:48am    
"threading, rather than user actions"

That's the way I also see it. 5+
I fixed OP question accordingly.
Are you talking about lock keyword which .net framework provide.

e.g.

object objLock = new object();
lock(objLock)
{
    //Do the required stuff here.
}
 
Share this answer
 
v2
Comments
JustWorking 20-Jun-11 9:48am    
ok how to unlock?
#realJSOP 20-Jun-11 10:31am    
Try googling it. You'll probably find out a lot more info about lock than what we could provide here in a single quick answer.
nit_singh 20-Jun-11 9:56am    
Actually unlock happens automatically once the execution is done
Manfred Rudolf Bihy 20-Jun-11 10:44am    
The execution of the locked block, that is! ;)
Manfred Rudolf Bihy 20-Jun-11 10:47am    
I'm pretty sure that is what OP wanted! 5+

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900