Solved

Lock table before insert

Posted on 2010-11-28
19
1,506 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
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.
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.

860 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