By: Steven Holzner Emailed: 1785 times Printed: 2623 times
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.
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.
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).
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.
You also can easily navigate through a dataset that's been bound to controls
Most Viewed Articles (in VB.net )
Latest Articles (in VB.net)
Comment on this tutorial
- Cloud Computing
- Java Beans
- Mac OS X
- Office 365
- Tech Reviews