Using a DataAdapter for each table in my database

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a database with quite a few tables in it.
Is it good practice to use a different DataAdapter
for each and every table i want to use in my
application? Or should I use a single DataAdapter
to fill all the tables I need?

Thanks.
 
it is good practice not to use DataAdapters at all, and to instead use a
proper architecture.

--
Regards

Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)
(CTO PowerNodes Ltd.)
 
I think what Thomas meant was, it takes more than "how many tables" to
decide between single data adapter versus many, or data adapter versus even
data reader.
Also that you probably want to abstract all this out to a data layer - which
you might have already done.

But one data adapter versus many - there is too little info for me to
comment upon accurately. Though I do disagree with "it is good practice not
to use DataAdapters at all". DataAdapters rock.

- Sahil Malik
Independent Consultant
You can reach me thru my blog at -
http://www.dotnetjunkies.com/weblog/sahilmalik/
 
Hi,

You could use single DataAdapter, but you could use different Command
classes for each table. I think it more depends on what you need to do.
 
Well, I was thinking that since each DataTable
needs its own set of commands (insert, update, delete and sql),
i needed to have seperate DataAdapters for each DataTable.
This is where i get confused. Since each DataAdapter contains
the relevant commands for each table, is it ok to have a DataAdapter
for each DataTable, even when the client keeps quite a few
tables in memory at once, or using too much DataAdapters
at once is unnecessary, and it can be done with only one, or a lot
less DataAdapters (which i really like using, actually. They're very
handy and easy to use ;-) ).

Thanks.
 
I create all the DataAdapters in code, so I think of the DataAdapter as a
disposable bridge between the DataSet and the database. You use it to fill
the DataSet with a table (or update the real table) and you *may* be done
with it. However, you hit upon the real issue: you DO need insert, update,
delete commands, as well as your queries, for EACH table. Now how you do
that *may* determine how many adapaters you use. For my purposes, I do not
use the drag-drop DAs but instead use those to simply help generate the
sometimes windy and complicated Insert/Update logic.

Tackling ADO.Net really takes a good book, it's hard to muck around in the
newsgroups (despite some excellent advice from the MVPs and others) and pull
all of the concepts together.
 
Thank you, thank you, thank you!

I now have some expert advice on my situation
from some of the best brains in the business.
You guys are second to none!

Thanks again :-)
 
Back
Top