Any application will have just one DataSet which will contain one or more DataTables.
A DataSet provides you with the ability to create multiple tables and fill them with data from different sources and enforce relationships between pairs of tables.
The DataSet represents a complete set of data including tables, constraints and relationships among the tables.
A dataset is a multi-tabled disconnected cache of data.
The structure is similar to a relational database (tables, rows, columns, constraints, relationships).
You can store any type of object in a DataSet, including forms, controls and custom objects.
You should work with a dataset when you are working with multiple tables.
Typed or Untyped ?
Datasets can either be typed or untyped.
Typed Datasets - is first derived from the base Dataset class and then uses information in an XML source file (.xsd) to generate a new class.
Untyped Datasets - has no corresponding built-in schema. The table, rows and columns etc are only exposed as collections. A web service that returns an object of type System.Data.Dataset returns an untyped dataset.
Creating a DataSet Object
Dim objDataSet As System.Data.DataSet
objDataSet = New System.Data.DataSet
objDataSet.DataSetName = "MyDataSet"
Alternatively you could pass the name of the dataset string directly to the constructor
Dim objDataSet = New System.Data.DataSet("MyDataSet")
If the name of the DataSet is not specified then the defualt name "NewDataSet" will be used.
You can use the GetChanges method to return a DataSet that contains just the changes.
You should then check for errors in each DataTable by examining the HasErrors property
If a DataTable has errors you should use the GetErrors method to return an array of DataRows that contain errors.
On each row you can examine the RowError property for more information.
Once the errors have been corrected Merge the two DataSets together
Call the DataAdapter.Update method
DataSet.AcceptChanges or DataSet.RejectChanges
Dim objDataSetChanges As System.Data.DataSet
objDataSetChanges = objDataSet.GetChanges(DataRowState.Modified)
If objDataSetChanges.HasErrors = True Then
For Each objDataTable In objDataSetChanged.Tables
If objDataTable.HasErrors = True Then
|CaseSensitive||True if string comparisons are case sensitive.|
|DataSetName||The name of this DataSet object.|
|DefaultViewManager||Returns a DataViewManager object allowing you to create custom search and filter settings for the DataTable objects in this DataSet.|
|EnforceConstraints||True if constraint rules are enforced when attempting an update opreation.|
|ExtendedProperties||Returns the PropertyCollection object used to store custom information about this DataSet.|
|HasErrors||Returns True if there are errors in any of the DataTable objects in this DataSet.|
|Locale||The CultureInfo onject containing the locale information used to compare strings in this DataSet,.|
|Namespace||The namespace for this DataSet, used when importing or exprting XML data.|
|Prefix||The XML prefix for the DataSet namespace.|
|Relations||Returns the collection of DataRelation objects.|
|Tables||Returns the collection of child DataTable objects.|
|AcceptChanges||Commits all changes to this DataSet after it was loaded or since the most recent AcceptChanges method.|
|Clear||Clears all the data in the DataSet.|
|Clone||Creates a cloned DataSet that contains the identical structure, tables and relationships as the current one.|
|Copy||Creates a DataSet that has both the same structure and the same data as the current one.|
|GetChanges||Gets a DataSet that contains all the changes made to the current one since it was loaded or since the most recent AcceptChanges method, optionally filtered using the DataRowState argument.|
|GetXml||returns the XML representation of the contents of the DataSet.|
|HasChanges||Returns True if the DataSet has changed. It takes an optional DataRowState argument that lets you check for modified, inserted or deleted rows only.|
|InferXmlSchema||Infers the XML schema from the TextReader or from the file into the DataSet.|
|Merge||Merges the current DataSet with another DataSet, a DataTable or an array of DataRows.|
|ReadXml||Reads an XML schema and data into the DataSet|
|ReadXmlSchema||Reads an XML schema into the DataSet|
|RejectChanges||Rejects all changes to this DataSet after it as loaded or since the most recent AcceptChanges method.|
|Reset||Resets the DataSet to its original state.|
|WriteXml||Writes the XML schema and data from the current DataSet.|
|WriteXMLSchema||Writes the current DataSet's structure as an XML schema|
|MergeFailed||Fires when two DataSet objects being merged have the same primary key value and the EnforceConstraints property is True.|
© 2020 Better Solutions Limited. All Rights Reserved. © 2020 Better Solutions Limited TopPrevNext