O'Reilly logo

Sams Teach Yourself ADO.NET in 24 Hours by Paul Bertucci, Jason Lefebvre

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required