Table Adapter and multi-user environment

I am writing my first .NET application after years of using VB 6.0. As I understand it, the new table Adapter takes a "snapshot" or "cache" of the records in the table, until you TableAdapter.Update.

Is this OK in a multi user environment I am writing an inventory program. I want to avoid the following problem...

POS computer A sells an item, so my program changes it's quantity from 12 to 11. Two minutes later POS computer B sells one of that same item. It's Table Adapter's cache or snapshot may still think there are 12 of that item, and it would do the same calculation, and it would appear like there were 11 of the item now in stock, when in reality there is only 10, because 1 was sold from each computer.

Does the TableAdpater on the second computer realize that the record has changed (two minutes earlier) and update itself or should i use the traditional data adapter which (as faras i can tell) works with the database "in place", as opposed to cached copy

I love the drag and drop functionality from the data sources pane. Is there an equivalent way to create bound controls (details style) from the traditional data adapter



Answer this question

Table Adapter and multi-user environment

  • Vincent Tsui

    Thank you very much for that great answer! I actually have some books on ADO.net such as ADO.NET: From Noice to Pro

    Visual Basic .NET Edition from Apress

    I will take your advice on getting deep into the code that is created.

    Maybe I will use the new drag and drop shortcut method to get all the controls on the form and modify as neccessary though, cause i love the look that they create.

    From what you say about the tables adapter only being a "wrapper" for the base controls, this probably won't be too difficult

    Thanks again!


  • lukecarpenter169

    Thanks, I'll google that, but I kinda bet that what I find will refer to .NET before 2005

    I guess my dilemna is I am wondering if the new table adapter can perform admirably in this environment.

    This is my first application since VB 6.0, and I guess if I am going to learn something new, I'd prefer to jump to the newest technology available, but I just want to make sure before I start designing my forms that the new table adapter can be suitable for a multi user data environment.  (I'll tweak it for multi user later in development, so right now it's more important to know if the tool can handle what i need, than it is for someone to tell me exactly how to do it)

    I know someone more experienced than me would be best to answer yes or no, and that i could probably google for a month of sundays and not answer my own question.  This tables adapter thing being so new and all.


  • AlexB-007

    There are good articles on the web on how to fullfill ACID (transactions) with .NET


  • cnSZlzl

    I suggest you read more on DataSets and DataTables.

  • Jim Stallings

    I've been reading for a while... Anything in particular that I am looking for I am trying to evaluate before I begin a large project, if I should be using the table adapter/data connections wizard, or the traditional data adapter and which works best in the multi user situation that I described.


  • Germano Freitas

    You are quite right to worry about how you application will work in a multi-user environment. The major difference from VB6 is that you users will all be working with their own copy of the data and this can create major problems.

    At some point you are going to have to deal with concurrency issues where one user has already changed the data and has updated the source database and then another user attempts to change the same data but using the original data not the data that is now in the source database. Most books on ADO.Net programming have whole chapters on this one issue. This is not a new problem that has arisen with the the introduction of the table adaptor class but has always been an issue (the table adaptor is just a wrapper around the basic data adapter class that has always been in .Net).

    How you actually tackle the problem will depend on your specific issues. In your case when your user clicks the save button the application needs to check that the data that the user was updating was still the same as the data that is in the source database, if it is not, then it needs to tell the user about this and bring down the new data so that they can try again. Basic advice is to only ever pull down the data you actually need to do the specific job and pull it down as late as possible and then update the source database as soon as you have finished with it.

    Whilst you can build basic applications just by dragging and dropping controls onto forms, you do really need to know what code is being generated for you behind the scene so that you can be fully in control of your application; eventually you will need to start building applications from scratch. Invest in a good book, 'Pro ADO.NET 2.0' by Sahil Malik (Apress) is a great book for all levels of programming.

    So yes you can do what you are wanting to do, using table adapters if you think that is the best way, but at some point you are going to need to get your hands dirty at the nitty gritty code level.

    Have fun with .Net, it's a massive leap forward from VB6, so much more powerful and writing apps can be a lot of fun.



  • Nino Benvenuti

    Thanks, I'll read up on that stuff


  • Table Adapter and multi-user environment