Questions That Should Be Asked More Frequently

Q

So the SqlDataAdapter can fill a DataSet with the results of a query and submit changes stored in a DataSet to my database. Do I have to use the same object to accomplish both tasks? I’m working with multi-tiered applications, and it sounds like I need to keep my SqlDataAdapter objects alive in the middle tier between calls from the client application. Is that the case?

A

You can use the same SqlDataAdapter to fill your DataSet and submit changes to your database, but that’s not a requirement.

Suppose that your middle-tier object has two simple methods—one to return a new DataSet and one to submit the pending changes in your DataSet to your database. You can use separate SqlDataAdapter objects for each ...

Get Programming Microsoft® ADO.NET 2.0 Core Reference, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.