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

Adding and Removing Data

At this point, the schema of the DataSet is entered and you're ready to add some data. Recall that the column collection of the DataTable defines the schema, and the rows collection of the DataTable defines the data. In other words, to add data to our DataTable, all we need to do is add some rows to our DataTable: dtEmployees.

DataRows Contain Data

Adding rows to the dtEmployees DataTable is easy to do. First, you need to use the NewRow() method of the dtEmployees object. NewRow() returns a reference to a new row for your DataTable. Next, you must specify values for the columns in the newly created row. Lastly, you must add the row to the DataTable. Listings 2.3 and 2.4 demonstrate this by adding a few rows to our existing ...

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