DataAdapter newbie question

  • Thread starter Thread starter J L
  • Start date Start date
J

J L

I have two questions regarding the use of DataAdapters:

1. If I am going to retrieve multiple tales to a DataSet using
multiple DataAdapter Fill's is it best to create a separate
DataAdapter for each table or to create one and change it's
SelectCommand property between each Fill?

2. Related to number 1, is it best to explicitly open the connection
before the series of Fill's and close after rather than allow each
DataAdapter to implicitly open and close the connection.

TIA,
John
 
Use separate dataadapter for each table. This way the run time
performance of your code will be faster when compared with reusing the
dataadapter sequentially.

You are right on the second one. use only one connection and close it
when the job is done or errors out (close it in the finally block).
This way, you can also implement transactions easily
 
when the job is done or errors out (close it in the finally block).
I've read that you can use a using{ //block of code } and it will
automatically run the dispose methods (is that correct?). Can I use this
pattern instead of putting in try{}catch{}finally{} blocks?

I'm a newbie just getting into ADO, so if I've confused you, please help
straighten me out (gently :>) as I am looking to learn.

Thanks!
 
Back
Top