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

  • SEARCH
  • Home
  • 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 8015265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:12:21+00:00 2026-06-04T20:12:21+00:00

The current situation is that there is a databound data grid view that many

  • 0

The current situation is that there is a databound data grid view that many people need to make changes to on a daily basis simultaneously. The grid has to be able to save and update but it is not working correctly since it is very active.

Here’s the scenario:

  1. 3 people open the grid form at the same time.
  2. They make changes to 3 different rows of data.
  3. Person 1 saves changes and is successful.
  4. Person 2 Saves changes and is successful but person 1’s changes are now gone since person 2’s grid was not synced with the data that person 1 just submitted.
  5. Person 3 saves changes and wipes out anything that person 1 and 2 did because person 3’s data grid view was not synced up with the updated data.

I have tried this approach first:

    private MySqlDataAdapter da;
    private MySqlConnection conn;
    BindingSource bs = new BindingSource();
    DataSet ds = null;
    string qry;
    string ConnString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];

    // THE LOAD METHOD
    private void LoadDataToGrid(string srcTable, string query)
    {
        conn = new MySqlConnection(ConnString);
        // ADD ANY QUERY
        qry = query;
        da = new MySqlDataAdapter(qry, conn);
        conn.Open();
        ds = new DataSet();
        MySqlCommandBuilder cb = new MySqlCommandBuilder(da);

        // USE TABLE NAME
        da.Fill(ds, srcTable);
        //USE TABLE NAME
        bs.DataSource = ds.Tables[srcTable];
        dataGridView1.DataSource = bs;

        // CUSTOMIZE GRID
        txtRows.Text = dataGridView1.Rows.Count.ToString();
        dataGridView1.AutoResizeColumns();
        dataGridView1.AllowUserToDeleteRows = false;
    }

    // THE SAVE METHOD
    private void SaveDataFromGrid(string srcTable)
    {
        // USE TABLE NAME
        DataTable dt = ds.Tables[srcTable];
        this.dataGridView1.BindingContext[dt].EndCurrentEdit();
        this.da.Update(dt);

        txtRows.Text = dataGridView1.Rows.Count.ToString();
    }

This did not work out for me because of the reasoning above. Data just wasen’t getting saved correctly.

Here was my second thought, but still suffers from above issue:

   // Load event
   dataGridView1.DataSource = context.TableName;

   // btnSave_click Event
   connection.open();

       // loop through cells in current row and apply changes by id

   context.tableName.Attach(DataFromGrid);
   context.ObjectStateManager.ChangeObjectState(DataFromGrid, System.Data.EntityState.Modified);
   context.savechanges();

Basically, how can I solve this disconnection problem? Has anyone had this issue before?

  • 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-06-04T20:12:22+00:00Added an answer on June 4, 2026 at 8:12 pm

    This issue is probably more complicated than one code snippet is going to solve. It seems like you have a couple of things to resolve first, before you get into the implementation;

    Firstly; does each person’s changes actually have to commit an entire grid? According to your scenario, each person changes a different row of data. Modifying your code to commit changes to just the row that was modified will cut down your conflict scenarios considerably.

    Secondly, and regardless of whether the conflicts are occurring in one row or many, you need to decide how to manage conflicts (you’ve not noted what you expect to happen – e.g; database wins, user’s choice, ett.).

    EF implements an optimistic concurrency mode (no database locks), however by default it will just elect to overwrite database changes when you commit your local changes. You need to modify your EF configuration to set ConcurrenyMode=Fixed so that it will not automatically overwrite changes when you have not ‘gotten latest’ before committing rows.

    See here for a bit more info on how EF handles concurrency: http://msdn.microsoft.com/en-us/library/bb738618.aspx

    Once you’ve modified the EF config, you’ll start getting exceptions when conflicts are detected, which you’ll need to handle, by refreshing the data either in the database (with local changes) or refreshing the local data (with database changes).

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

Sidebar

Related Questions

The current situation is that topics are sorted by 3 main categories. There is
I am using Asp.Net/C# in my application.My current situation is that I am using
Here's the situation... Right now, there's a site that's being hosted (DNS is already
This is my current situation: Im trying to execute a website that access to
We have one perplexity about current situation with TFS. There are 3 branches: Develop,
In my current situation I have a class that performs an operation synchronously. During
Current situation: Ubuntu 8.04 server edition (live server) Postgresql 8.3.7 (from standard repositories) Postgis
Current situation date (nvarchar(9)) sku (nvarchar(5)) smith (decimal) jones (decimal) jonson (decimal) nguyen (decimal)
My current situation is: I have to read a file and put the contents
let me explain my current situation i have a SharePoint site lets say it

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.