none
How can i insert/update data into single machine with multiple user.? RRS feed

  • Question

  • Dear Sir I'm using vb.net with LINQ to insert/update data into single machine with multi user. Now my question is how to stop other user while other user inserting/updating data?. Actully i'm using trigger also because for maintaint balance.

    Help me how can i perform this task with vb.net LINQ and how to restrict other user while other user doing task on table.?

    Saturday, December 9, 2017 7:42 AM

All replies

  • Which kind of LINQ are you using to insert data to database? Show some details.

    If you use Entity Framework, then check this resource too: https://forums.asp.net/default.aspx/16?Data+Access.

    In case of SQL, I think that one of the solutions is using transactions (BEGIN TRANSACTION, COMMIT TRANSACTION and ROLLBACK TRANSACTION statements in SQL, or VB classes like SqlTransaction). It depends on details.


    • Edited by Viorel_MVP Saturday, December 9, 2017 10:05 AM
    Saturday, December 9, 2017 10:03 AM
  • That is something we did in 1980 when a database had on table. Currently it means we lock with that the whole database because of all relations. 

    Since around 1990 we only look if something is changed, which has the name optimistic concurrency. 

    https://en.wikipedia.org/wiki/Optimistic_concurrency_control

    If it is quite normal that more users at the same minute  change the same data. You better can create data items special for those users. 

    Mostly you do it by trapping concurrency errors. But as Viorel wrote already, telling that you use Linq is as telling that you are a human.


    Success
    Cor

    Saturday, December 9, 2017 10:37 AM
  • Dear Sir I'm using vb.net with LINQ to insert/update data into single machine with multi user. Now my question is how to stop other user while other user inserting/updating data?. Actully i'm using trigger also because for maintaint balance.

    A trigger to do what?

    The concurrency issue of preventing more than one  user from working on the same record concurrently should only by applied when updating a record and not inserting a record.

    The one I use is the timestamp check along with user-id. If either one of them changes, then a user saved the record on an update before another user could save the record when one or more users are trying to update the same record concurrently.

    You can use an insert and update triggers to control the uer-id and timestamp or just the timestamp while you save the user-id manually.

    https://www.codeproject.com/Articles/114262/ways-of-doing-locking-in-NET-Pessimistic-and-opt

    Saturday, December 9, 2017 1:12 PM