dataadapter vs tableadapter - whats the difference?

  • Thread starter Thread starter HONOREDANCESTOR
  • Start date Start date
H

HONOREDANCESTOR

I have a book called "Hitchhiker's Guide to Visual Studio and SQL
Server". It has a chapter on using dataAdapters, and another chapter
on using tableAdapters. The problem is, they seem to overlap in what
they can do, and I don't know when I would use one and when I would
use the other? Furthermore VB 2003 seemed to use one, and VB 2005
seems to use the other mostly (at least when you drag and drop).
If I just want to learn the latest method of using VB-2005 with
databases, should I learn both adapters? Or just the Table Adapter?
And how would I know, in a given application, which one to choose?
Thanks,
HA
 
A TableAdapter is a visual component that VS uses to "show" you the details
of your connection and dataadapter. You wouldn't, for example, make an
instance of one of these in code and use it that way. A DataAdapter is
still the actual object that bridges the gap between the connected and
disconnected ADO .NET objects and, if you were writing code to perform your
data access, you'd use this.
 
Hi,

In version 2003 we had the DataAdapter and the Dataset. A part of the
dataset is the DataTable. For some who were used to the recordset that was
to difficult.

Then we got the TableAdapter as stand alone part in version 2005, because
that would be the solution, however probably not as wanted because now for
2008 we have Linq.

(Spoken this means in Dutch "tricky or dangerous").

I don't know why that name is choosen, however I am not yet able to give a
realistic opinion about Linq to be able to presume what there will be in
2011.

I know from a message the ideas of the writer of the Hitchhiker about this,
he will probably use other/more words to answer (By instance because he can
start earlier in past). However his intention will probably not be much
different.

:-)

Cor
 
Having written the book, perhaps I should elaborate further.

A DataAdapter is a Framework class used to construct untyped DataSet objects
by populating the Tables collection with the rowsets returned by the
SelectCommand. This class also supports an Update method that permits you to
define Update, Insert and Delete Commands for a single table. While the
DataAdapter can populate a DataSet with many tables, it can only make
changes to one of these--unless you jump through some hoops as I explain in
the book.

A TableAdapter is a Visual Studio-generated class to generate strongly typed
DataTable classes--including code to update the DataTable. It is a bindable
mechanism to manage a single rowset--usually derived from a SELECT against a
single table.

While both of these mechanisms can be populated with the rowset returned by
a JOIN, they do not provide a means to update the root database Table--as
possible in some cases in ADO classic.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant, Dad, Grandpa
Microsoft MVP
INETA Speaker
www.betav.com
www.betav.com/blog/billva
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
 
A much simpler explanation is a TableAdapter does a bunch of stuff. It
delegates the fill and update methods to a private DataAdapter. After using
it, I equated the TableAdapter as a DataAdapter with training wheels -
something to get started with but certainly nothing to finish with.

If you 1) use SQL Server, 2) use GetChanges() and 3) want to get the
autoincrement keys back, then you must trap the row updated event to skip
the inserts. If you don't believe this, examine the DiffGrams. While the
DataAdapter exposes these events, the TableAdapter does not. With a partial
class, you can add a public property to expose the underlying DataAdapter.
 
Back
Top