Solved

Lock table before insert

Posted on 2010-11-28
19
1,492 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now