Solved

Lock table before insert

Posted on 2010-11-28
19
1,502 Views
Last Modified: 2013-11-11
hi all ,,,
i am working on funcation to insert some data in a table using Linq to sql .. and i am facing a problem where i dont know how to lock a table untill i finish inserting .. i dont want any other users to be able to inster into it but i want them to be able to update it and select from it.
0
Comment
Question by:VCyrus
  • 7
  • 5
  • 2
  • +1
19 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 34225271
>>i dont want any other users to be able to inster into it but i want them to be able to update it and select from it.

To the best of my knowledge - impossible.
0
 
LVL 1

Author Comment

by:VCyrus
ID: 34228236
hi ,,,
if that is impossible , can i just lock it when i am inserting and block any other users from doing any other operation ???
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 34228277
In theory yes.  It can depend on the database and drivers you are coding with.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 1

Author Comment

by:VCyrus
ID: 34228299
and the way to do this is ????

i am currenty working with C# , LINQ2SQL and SQLserver in windows forms application.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 34228517
I know that some SQL drivers in .NET don't offer as many options as in the unmanaged world.

Does the following link help you - it is about locking in SQL Server.
http://www.sqlteam.com/article/introduction-to-locking-in-sql-server
0
 
LVL 1

Author Comment

by:VCyrus
ID: 34228972
Sorry ..
no, this is not what i am looking
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 34228984
If the option you want isn't available then it isn't available and you can't do what you wanted.
0
 
LVL 1

Author Comment

by:VCyrus
ID: 34229417
the link you have provided is talking about SQL statements ...
i said that i am looking for linq to sql solution ..
how can i - using linq to sql  - do single insert for one user and block others who want to insert at the same time .
 
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 34229492
>>the link you have provided is talking about SQL statements ...

Yes, it describes how to lock a table under different scenarios, such as when you are inserting data.  If it isn't supported by the driver you use then one is stuck.

From an earlier comment:
I know that some SQL drivers in .NET don't offer as many options as in the unmanaged world.
0
 
LVL 1

Author Comment

by:VCyrus
ID: 34236815
i am still looking for other solution under linq
0
 
LVL 19

Expert Comment

by:Shahan Ayyub
ID: 34388595
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 34626185
The original question was answered.  No is an acceptable answer.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 34635690
coment #34225271 answers the original question.  (At least I, and no other expert has offered a different opinion, think it is impossible)
0
 
LVL 19

Expert Comment

by:Shahan Ayyub
ID: 34675701
@AndyAinscow

Do you think there is no use of my comment in ID: 34388595 ???

Since I am not going to get points, but it should clear to me for knowledge.
0
 

Expert Comment

by:thermoduric
ID: 34709716
I am starting the auto-close procedure in this question. After moderator review, it would appear valid solutions were provided.

- thermoduric -
EE Community Support Moderator
http://www.experts-exchange.com/Q_26750827.html

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question