TableAdapter vs DataAdapter


  • Hi peolple,

    Can someone tell me the big difference between TableAdapter and DataAdapter?

    I have an application in 2005 express that connects with a ACCESS database.

    My querys will be mostly SELECT querys (looking for key in a table).

    Once in a while I will need to use sql command like INSERT INTO, and don't know if the TableAdapters Querys support this (I have tried with no success).

    Using the TableAdapters may be simple, but I have many problems with this solutions and the way of solving this was to delete the TableAdapters from the forms editor. I could not edit the DataSet in the Dataset Wizard. The problem was that all stored TableAdapter querys were lost, and I have to do all the work again...

    I want to choose the best path for my needs.

    Can someone advise me?




    Tuesday, December 5, 2006 7:27 PM

All replies

  • Hi,

    Using the TableAdapters is the simplest solution because it is integrated in VS. The disadvantage is that the designer has some problems like you saw when you lost your queries. If your database can schema changes or for more complicated you can use the DataAdapter which gives you more control over the data access.

    Hope this helps,

    Wednesday, December 6, 2006 1:07 AM
  • Hi again,

    How can I, using the DataAdapter perform the same querys like the ones in the TableAdapter?

    What about the UPDATE command?

    What if I need to do somethis besides SQL SELECT command (INSERT INTO)?

    Can you give me a practical example for this?

    My TableAdapter have simple querys, like search a row with specific key, select all rows where a specific field is = to...

    I also change the BindingSource connection string, as bellow:

    Dim MyConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dbBaseDados

    Me.CircuitosFonteTableAdapter.Connection.ConnectionString = MyConnection


    I want to clear this subject once and for all... if I can simple do it by using the DataAdapter instead, that just fine.

    Help, please



    Wednesday, December 6, 2006 2:33 AM
  • I recommend that you review the quickstarts and starter kits put out by Microsoft as a way to learn more about the technology.

    A whole bunch of good resources, including numerous books, that could really help you out:

    ASP.NET 2.0:

    Winforms: and

    The online MSDN Developer's Guide for Windows Form Applications is also indispensible:

    They will all teach you the basics of databinding and data access.



    Wednesday, December 6, 2006 4:19 AM
  • You can do update with the DataAdapter. Here's how.

    You need a data adapter for each table. For each dataadapter you need to set 4 properties: SelectCommand, UpdateCommand, DeleteCommand, InsertCommand. These four properties take Command objects that you initialize with the sql command (Select, Insert, Update, Delete...) and the parameters that they require. Once that's done, you use it in the same way as the table adapter: You call the Fill method to fill the dataset, and you call Update to update the database.



    Wednesday, December 6, 2006 4:22 AM