Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6736449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:07:51+00:00 2026-05-26T11:07:51+00:00

I have a Project Table, a Stakeholder Table, and an Association Table (which takes

  • 0

I have a Project Table, a Stakeholder Table, and an Association Table (which takes a ProjectID and a StakeholderID as foreign keys).

I want to delete a single Project but must first delete all that Project’s rows in the Association Table.

Here is the method. ProjectRow is a strongly typed DataRow created with the DataSet Designer.

 public void RemoveProject(ProjectRow project)
    {
        try
        {
            var associations = from a in ds.Association.AsEnumerable()
                               where a.Project == project.ProjID
                               select a;
            foreach (DataRow assoc in associations)
            {
                assoc.Delete();
            }

            project.Delete();

            using (TransactionScope scope = new TransactionScope())
            {
                assocTableAdapter.Update(ds.Association);

                System.Threading.Thread.Sleep(40000); // to test the transaction.

                projTableAdapter.Update(ds.Project);

                scope.Complete();
            }
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
    }

This method does achieve the effect required (stops associations being added to the deleted project during the transaction) but it seems to place a read and write lock on all the tables so I cannot even read from the Project Table during the sleep period.

I would like to be able to add other Project/Stakeholder pairs to the Association Table during the transaction. How do I achieve this?
Cheers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:07:51+00:00Added an answer on May 26, 2026 at 11:07 am

    A few links but you can hint that you’d like row level locking and the databaase engine may or may not take the suggestion. However, since you’re letting the library handle the deletes, who knows what it’s doing (short of turning on profiler and capturing statements). It could very well be issuing table locks or you simply have the misfortune of the row locks escalating to page locks and the rows you are attempting to access in your query outside the transaction happen to be on the same page.

    • Is it possible to force row level locking in SQL Server?

    • Why is SQL Server 2008 blocking SELECT's on long transaction INSERT's?

    • https://dba.stackexchange.com/questions/6512/difference-between-row-level-and-page-level-locking-and-consequences

    What’s a body to do? You need to balance your concurrency needs against your risk for bad data. Here’s a fun poster about SQL Server Isolation Levels

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project table with projectId as primary key: **projectId**, projectName, dateCreated, etc.
i have a project table which has a image_id field and a newsimage_id field.
I have a 3 table SQLServer Database. Project ProjectID ProjectName Thing ThingID ThingName ProjectThingLink
I have created a a subclass of Table in my ASP.NET project which creates.
I have the following table structure, which is imported into an Entity Framework project:
I have project which contain 4 tables among these shedule table Session column i
I have table project, screenshot, sub_screenshot, and user I want to achieve this kind
I have a project which requires a table that includes both fixed-width and flexible-width
I have a database table which stores a type for a project which stores
I have a table named Project, it has single primary index named Project_Id. Primary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.