We've already worked a good deal with the DataSet class, which is how datasets are supported in Visual Basic. A dataset is a cache of data retrieved from a database, and, as we know, it's the major component of ADO.NET. A DataSet object is made up of a collection of DataTable objects that you can relate to each other using DataRelation objects. You also can guarantee data integrity with the UniqueConstraint and ForeignKeyConstraint objects.
As we've discussed in Chapter 20, a dataset reads and writes data and schema as XML documents, which can be transported using the HTTP protocol, which makes it great for the Internet. You can save the schema as an XML schema with the WriteXmlSchema method, and the schema and data can be saved using the WriteXml method. If you need to read an XML document that includes both schema and data, use the ReadXml method that infers and creates a schema from the document. See "Writing Datasets to XML and Reading Datasets from XML" in this chapter.
When the user edits data in data-bound controls (or when you change data values in code), changes are made to the dataset's data immediately. You can use the GetChanges method to get a new dataset holding only the rows that have changed, and you typically send this new dataset to the database in the data provider with the data adapter's Update method. The data provider may make changes itself in the dataset of changes you send it (such as updating fields that hold calculated values, or adding primary keys) and return a new dataset, which you can then merge into the dataset you're working with, using the dataset's Merge method. Then you use the AcceptChanges method on the original dataset to accept the changes (or use RejectChanges to cancel the changes). See "Updating the Underlying Data Store" in the In Depth section of Chapter 21 for more details on this process.
Datasets can be typed or untyped; usually, datasets are typed in Visual Basic. A typed dataset is a dataset that is derived from the DataSet class and uses information in an XML schema file (an XSD file). An untyped dataset, on the other hand, has no built-in schema. An untyped dataset can contain tables, columns, and rows, but those are exposed only as collections.