Filling a DataSet with the DataAdapter
The Command object executes a query against a database. Alone, it can't place the results into a DataSet. This is where the DataAdapter object comes into the picture. One of the DataAdapter's jobs is to fill a DataSet with the results of a query. You can learn more about the DataAdapter in Hour 8, “Using the DataReader and DataAdapter.”
The DataAdapter object is instantiated in a very similar fashion to the Command object:
Dim myAdapter as New SqlDataAdapter( myCommand )
or in C#:
SqlDataAdapter myAdapter = new SqlDataAdapter( myCommand );
Notice that you pass the existing Command object you're working with to the new DataAdapter object you're creating. This tells the DataAdapter which Command object ...
Get Sams Teach Yourself ADO.NET in 24 Hours 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.