Free mag vol1 | Page 917

CHAPTER 22  ADO.NET PART II: THE DISCONNECTED LAYER HasChanges() Gets a value indicating whether the DataSet has changes, including new, deleted, or modified rows. Merge() Merges this DataSet with a specified DataSet. ReadXml() Allows you to define the structure of a DataSet object and populate it with data, based on XML schema and data read from a stream. RejectChanges() Rolls back all the changes made to this DataSet since it was created or since the last time AcceptChanges() was called. WriteXml() Allows you to write out the contents of a DataSet into a valid stream. Building a DataSet Now that you have a better understanding of the role of the DataSet (and some idea of what you can do with one), create a new Console Application named SimpleDataSet and import the System.Data namespace. Within the Main() method, define a new DataSet object that contains three extended properties that represent a time stamp, a unique identifier (represented as a System.Guid type), and your company’s name, as follows: static void Main(string[] args) { Console.WriteLine("***** Fun with DataSets *****\n"); // Create the DataSet object and add a few properties. DataSet carsInventoryDS = new DataSet("Car Inventory"); carsInventoryDS.ExtendedProperties["TimeStamp"] = DateTime.Now; carsInventoryDS.ExtendedProperties["DataSetID"] = Guid.NewGuid(); carsInventoryDS.ExtendedProperties["Company"] = "Mikko’s Hot Tub Super Store"; Console.ReadLine(); }  Note A GUID (a.k.a. a globally unique identifier) is a statically unique 128-bit number. A DataSet object is not terribly interesting until you insert any number of DataTables. Therefore, the next task is to examine the internal composition of the DataTable, beginning with the DataColumn type. 863