INFO: Roadmap for ADO.NET DataSet, DataView, and DataViewManager Objects
This article was previously published under Q313485 On This PageSUMMARY
This article provides a roadmap to learn and to master the ADO.NET DataSet, DataView, and DataViewManager objects. Roadmap articles provide links to useful information, including online documentation, Microsoft Knowledge Base articles, and Microsoft white papers, to help you learn about a Microsoft product or technology. Microsoft Knowledge Base How To articles and walkthroughs provide step-by-step instructions to accomplish specific tasks. QuickStart sample files are ready-made programs that illustrate a technique. For additional ADO.NET technology roadmap articles, click the article number below to view the article in the Microsoft Knowledge Base: 313590 (http://support.microsoft.com/kb/313590/EN-US/) INFO: Roadmap for ADO.NET
OverviewA DataSet is a disconnected data store that provides consistent functionality regardless of the data source. A DataSet also provides a bridge between relational organization of data (for example, a database) and hierarchical organization of data (for example, Extensible Markup Language).The DataSet is similar to an array of disconnected Recordset objects, but the DataSet offers more powerful functionality. The DataSet can maintain local constraints, cascade updates and deletions, and provide hierarchical navigation along relations. The DataSet also has a more powerful expression evaluator than Microsoft ActiveX Data Objects (ADO). This provides more flexibility when you search for and filter records. The DataSet also allows low-level control over row versioning and error state. A DataView provides a mechanism for sorting and filtering a single DataTable. A DataViewManager provides a mechanism for sorting and filtering multiple DataTable objects when you perform hierarchical navigation. For more information about the ADO.NET DataSet object, refer to the following Microsoft Web site:
ADO.NET DataSet http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcontheadonetdataset.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcontheadonetdataset.asp) Database-like Data Containers http://msdn2.microsoft.com/en-us/library/ms810289.aspx (http://msdn2.microsoft.com/en-us/library/ms810289.aspx) DataSetDataSet objects include the following elements:
The DataSet provides the functionality to read and to write Extensible Markup Language (XML) data and schema through the following methods:
The following list describes some of the methods and the properties of the DataSet:
Click here to view a list of How To articles about ADO.NET DataSet objects, as well as other related objects (http://search.microsoft.com/results.aspx?q=ADO.NET+DataSet+How+To+Articles+dataset+datatable&qsc0=2&FORM=QBME1&l=1&mkt=en-US&ft0=20000) Visual Studio .NET Help Documentation
Accessing Data with ADO.NET MSDN Articleshttp://msdn2.microsoft.com/en-us/library/e80y5yhx(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/e80y5yhx(vs.71).aspx) Creating and Using DataSets http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcreatingusingdatasets.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcreatingusingdatasets.asp) Creating a DataSet http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcreatingdatasetprogrammatically.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcreatingdatasetprogrammatically.asp) Adding a DataTable to a DataSet http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconaddingdatatabletodataset.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconaddingdatatabletodataset.asp) Adding a Relationship between Tables http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconaddingrelationshipbetweentwotables.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconaddingrelationshipbetweentwotables.asp) Navigating a Relationship between Tables http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconnavigatingrelationshipbetweentwotables.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconnavigatingrelationshipbetweentwotables.asp) Using a DataSet with Existing Data http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconusingdatasetwithexistingdata.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconusingdatasetwithexistingdata.asp) Merging DataSet Contents http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconmergingdatasetcontents.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconmergingdatasetcontents.asp) Copying DataSet Contents http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcopyingdatasetcontents.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcopyingdatasetcontents.asp) Working with DataSet Events http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconworkingwithdatasetevents.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconworkingwithdatasetevents.asp) These articles are from the Diving Into Data Access column.
Data Relations and Relatives QuickStart Sampleshttp://msdn2.microsoft.com/en-us/library/ms810294.aspx (http://msdn2.microsoft.com/en-us/library/ms810294.aspx)
How Do I...Save DataSet mappings to an XSD schema file? NOTE: If you installed the QuickStart samples on your computer, these samples are available in the \QuickStart\Howto\Samples\Xml folder.http://samples.gotdotnet.com/quickstart/howto/doc/Xml/SaveDataSetMapXSDSchema.aspx (http://samples.gotdotnet.com/quickstart/howto/doc/Xml/SaveDataSetMapXSDSchema.aspx)
The SaveDataSetMapXSDSchema sample demonstrates how to create DataTable objects and how to add DataRow objects in code, and then how to write the XML Schema Definition (XSD) to a stream.
How Do I...Save a DataSet as XML?http://samples.gotdotnet.com/quickstart/howto/doc/Xml/SaveDataSetXML.aspx (http://samples.gotdotnet.com/quickstart/howto/doc/Xml/SaveDataSetXML.aspx)
The SaveDataSetXML sample demonstrates how to create a DataTable in code, how to add DataRow objects in code, how to parse XML nodes, and then how to write to the console.
Microsoft Knowledge Base How To Articles 305346 (http://support.microsoft.com/kb/305346/EN-US/) HOW TO: Copy DataRows Between DataTables by Using Visual Basic .NET
308909 (http://support.microsoft.com/kb/308909/EN-US/) HOW TO: Copy DataRows Between DataTables by Using Visual C# .NET
308058 (http://support.microsoft.com/kb/308058/EN-US/) HOW TO: Obtain Extended Error Information in the DataSet by Using Visual Basic .NET
For a list of articles that contain helper functions to handle common DataSet manipulations (such as CREATE TABLE and SELECT DISTINCT equivalents, joins, and grouping) in a single function call, click the following link:
Click here to view the complete list of DataSetHelper articles (http://search.microsoft.com/results.aspx?q=How+to+ADO.NET+DataSetHelper+Articles&qsc0=2&FORM=QBME1&l=1&mkt=en-US&ft0=20000) DataTableA DataTable is a collection of metadata and data, where the metadata is described by a collection of DataColumn objects and Constraint objects, and the data is contained in a collection of DataRow objects. A DataTable may exist by itself or as part of a DataSet.Unlike the ADO Recordset object, which manipulates a Provider, the DataTable is a passive object. The DataAdapter object, the XmlDataDocument object, and the user code manipulate the DataTable. The DataTable does not know where its own data comes from. This data can come from multiple sources. The following list describes some of the methods and the properties of the DataTable:
DataColumnYou can use the DataColumn to define the attributes for a column in a DataTable or a DataRow (mainly the ColumnName and the DataType attributes). The DataColumn contains AutoNumber and Null support.The following list describes some of the properties of the DataColumn:
DataRowAlthough a DataRow may exist by itself, the DataTable or the DataRowBuilder must create the DataRow. For example, you can use the NewRow method of the DataTable to create the DataRow, or you can use a DataTable for schema of the DataRowBuilder to create the DataRow.The DataRow can have multiple states, including:
The DataRow can have multiple versions, including:
The following list describes some of the methods and the properties of the DataRow:
DataRelationThe DataRelation object defines the parent/child relation between two DataTable objects.The following list describes some of the properties of the DataRelation:
ExtendedPropertiesThe DataSet, the DataTable, the DataRelation, and the Constraint objects all support an ExtendedProperties collection where you can store user-defined attributes for that object.DataViewA DataView allows you to sort and filter records that you view. Each DataTable has a DefaultView object that you can access and set properties on. In addition, you can create a number of independent DataView objects on a DataTable. The DataView creates an index that is based on the sorted columns, which provides fast search capabilities through the Find method. This Find method only searches the current, sorted column. If the DataView is sorted on multiple columns, you must provide an array of values in the Find method.You can edit the Current value of fields in a DataTable row by simple assignment. The change is immediate. Alternately, you can use the BeginEdit method to change Proposed row versions and use the EndEdit or the CancelEdit method to commit or roll back your changes. You cannot directly edit data rows in the DataView. You must use the BeginEdit, the EndEdit, and the CancelEdit methods instead. After you call the EndEdit method, the changes are written to the DataTable and are available immediately. Other DataView objects on the same DataTable are notified of the changes. By default, a DataView binds to the Current rows. You can pass a DataViewRowState to the constructor to bind to other row versions (for example, to access Deleted records). NOTE: You can only bind a DataView to a single DataTable. You cannot make a DataView filter another DataTable after you create the DataView. The ListChanged event is raised whenever the underlying filtered or sorted data is changed. Visual Studio .NET Help Documentation
Creating and Using DataViews MSDN Articlehttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcreatingusingdataviews.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcreatingusingdataviews.asp) The following article is from the Diving into Data Access column.
Views and Filters QuickStart Sampleshttp://msdn2.microsoft.com/en-us/library/aa728815(VS.71).aspx (http://msdn2.microsoft.com/en-us/library/aa728815(VS.71).aspx)
This article addresses both DataView and DataViewManager objects, as well as architectural information. This article also compares these objects to Recordset clones.
http://samples.gotdotnet.com/quickstart/howto/doc/adoplus/FilterData.aspx (http://samples.gotdotnet.com/quickstart/howto/doc/adoplus/FilterData.aspx) NOTE: If you installed the QuickStart samples on your computer, these samples are available in the \QuickStart\Howto\Samples\Adoplus folder.
The FilterData sample fills a DataSet by using the SqlDataAdapter object and then uses DataView to filter the DataTable.
Microsoft Knowledge Base Article 325682 (http://support.microsoft.com/kb/325682/EN-US/) HOW TO: Implement a Custom DataView Class in Visual Basic .NET
DataViewManagerIf you navigate to child records through a DataView or DataTable, the child records are unfiltered (except with regard to the parent records). The DataViewManager allows you to specify the RowFilter and the Sort properties that are applied when you perform hierarchical navigation.For example, if you bind a Windows Form DataGrid control to a DataSet that contains a list of customers and orders, when you navigate to the orders for a particular customer, all orders are displayed. However, if you bind the DataGrid to a DataViewManager, and if you add a DataViewSetting object to the DataViewManager.DataViewSettings collection, you can filter the list of orders to display only those orders that exceed a certain monetary amount. In addition, you can filter the list of orders and sort them in descending order according to the order amount. Visual Studio .NET Help Documentation
Setting Default Table Views Using a DataViewManager MSDN Articlehttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconsettingdefaulttableviewsusingdataviewmanager.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconsettingdefaulttableviewsusingdataviewmanager.asp) This article is from the Diving into Data Access column.
Views and Filters http://msdn2.microsoft.com/en-us/library/aa728815(VS.71).aspx (http://msdn2.microsoft.com/en-us/library/aa728815(VS.71).aspx)
This article addresses both DataView and DataViewManager objects, as well as architectural information. This article also compares these objects to Recordset clones.
TroubleshootingIf you encounter problems and need answers to your questions, consult the MSDN newsgroups or the Microsoft Knowledge Base. In the MSDN newsgroups, you can share your experiences with your peers.
MSDN Newsgroups http://msdn.microsoft.com/newsgroups/ (http://msdn.microsoft.com/newsgroups/) Searching the Knowledge Base http://support.microsoft.com/search/?adv=1 (http://support.microsoft.com/search/?adv=1)
| Article Translations
|
Back to the top
