Results 1 to 2 of 2

Thread: VS 2005 TableAdapter vs DataAdapter

  1. #1

    Thread Starter
    Addicted Member corwin_ranger's Avatar
    Join Date
    Sep 2004
    Location
    CT
    Posts
    198

    VS 2005 TableAdapter vs DataAdapter

    Can anyone describe or provide a link describing the differences between a DataAdapter and TableAdapter as it applies in 2005? Everything I've seen so far on MSDN and in books describes them in VERY similar terms. I'm just trying to understand where to use one rather than the other.

    Thanks,

    Steve

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: VS 2005 TableAdapter vs DataAdapter

    I just read about this very same thing in MSDN2 myself last night. I haven't played with them yet but it appears that TableAdapters are created for you when you drag a data source onto a form to create an instance of a strongly-typed DataSet. The following is from the MSDN Express help topic entitled "TableAdapter Overview " and it seems pretty explicit to me.
    TableAdapters provide communication between your application and a database. More specifically, a TableAdapter connects to a database, executes queries or stored procedures, and either returns a new data table populated with the returned data or fills an existing DataTable with the returned data. TableAdapters are also used to send updated data from your application back to the database.

    Users of previous versions of Visual Studio can think of a TableAdapter as a DataAdapter with a built-in connection object and the ability to contain multiple queries. Each query added to a TableAdapter is exposed as a public method that is simply called like any other method or function on an object.

    In addition to the standard functionality of a DataAdapter, TableAdapters provide additional typed methods that encapsulate queries that share a common schema with the associated typed DataTable. In other words, you can have as many queries as you want on a TableAdapter as long as they return data that conforms to the same schema.

    In the previous version of Visual Studio, ADO.NET Data Adapters were used for communicating between an application and a database. While data adapters are still a main component of .NET Framework Data Providers, TableAdapters are designer-generated components that improve upon the functionality of DataAdapters. TableAdapters typically contain Fill and Update methods to fetch and update data in a database.

    TableAdapters are created with the Dataset Designer inside of strongly typed datasets. You can create TableAdapters during creation of a new dataset with the Data Source Configuration Wizard. You can also create TableAdapters in existing datasets with the TableAdapter Configuration Wizard or by dragging database objects from Server Explorer onto the Dataset Designer. For more information, see How to: Create TableAdapters.

    While TableAdapters are designed with the Dataset Designer, the TableAdapter classes generated are not generated as nested classes of the DataSet. They are located in a separate namespace specific to each dataset. For example, if you have a dataset named NorthwindDataSet, the TableAdapters associated with the DataTables in the NorthwindDataSet would be in the NorthwindDataSetTableAdapters namespace. To access a particular TableAdapter programmatically, you must declare a new instance of the TableAdapter.
    My signature contains links to multiple .NET 2.0 samples so I'm sure you could get a look at TableAdapters in action, although I'd guess that you'd probably need SQL Express installed to use them.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width