Solved

Lock table before insert

Posted on 2010-11-28
19
1,515 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

688 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