System.Data Namespace
Represents an in-memory cache of data.
Visibility |
Name |
Parameters |
Return Type |
public |
AcceptChanges |
( )
|
Void
|
public |
BeginInit |
( )
|
Void
|
public |
Clear |
( )
|
Void
|
public |
Clone |
( )
|
DataSet
|
public |
Copy |
( )
|
DataSet
|
public |
CreateDataReader |
(
DataTable
dataTables
)
|
DataTableReader
|
public |
CreateDataReader |
( )
|
DataTableReader
|
protected |
DetermineSchemaSerializationMode |
(
XmlReader
reader
)
|
SchemaSerializationMode
|
protected |
DetermineSchemaSerializationMode |
(
SerializationInfo
info
,
StreamingContext
context
)
|
SchemaSerializationMode
|
public |
EndInit |
( )
|
Void
|
public |
GetChanges |
(
DataRowState
rowStates
)
|
DataSet
|
public |
GetChanges |
( )
|
DataSet
|
public static |
GetDataSetSchema |
(
XmlSchemaSet
schemaSet
)
|
XmlSchemaComplexType
|
public |
GetObjectData |
(
SerializationInfo
info
,
StreamingContext
context
)
|
Void
|
protected |
GetSchemaSerializable |
( )
|
XmlSchema
|
protected |
GetSerializationData |
(
SerializationInfo
info
,
StreamingContext
context
)
|
Void
|
public |
GetXml |
( )
|
String
|
public |
GetXmlSchema |
( )
|
String
|
public |
HasChanges |
(
DataRowState
rowStates
)
|
Boolean
|
public |
HasChanges |
( )
|
Boolean
|
public |
InferXmlSchema |
(
TextReader
reader
,
String
nsArray
)
|
Void
|
public |
InferXmlSchema |
(
String
fileName
,
String
nsArray
)
|
Void
|
public |
InferXmlSchema |
(
XmlReader
reader
,
String
nsArray
)
|
Void
|
public |
InferXmlSchema |
(
Stream
stream
,
String
nsArray
)
|
Void
|
protected |
InitializeDerivedDataSet |
( )
|
Void
|
protected |
IsBinarySerialized |
(
SerializationInfo
info
,
StreamingContext
context
)
|
Boolean
|
public |
Load |
(
IDataReader
reader
,
LoadOption
loadOption
,
DataTable
tables
)
|
Void
|
public |
Load |
(
IDataReader
reader
,
LoadOption
loadOption
,
String
tables
)
|
Void
|
public |
Load |
(
IDataReader
reader
,
LoadOption
loadOption
,
FillErrorEventHandler
errorHandler
,
DataTable
tables
)
|
Void
|
public |
Merge |
(
DataRow
rows
,
Boolean
preserveChanges
,
MissingSchemaAction
missingSchemaAction
)
|
Void
|
public |
Merge |
(
DataRow
rows
)
|
Void
|
public |
Merge |
(
DataTable
table
,
Boolean
preserveChanges
,
MissingSchemaAction
missingSchemaAction
)
|
Void
|
public |
Merge |
(
DataTable
table
)
|
Void
|
public |
Merge |
(
DataSet
dataSet
,
Boolean
preserveChanges
,
MissingSchemaAction
missingSchemaAction
)
|
Void
|
public |
Merge |
(
DataSet
dataSet
,
Boolean
preserveChanges
)
|
Void
|
public |
Merge |
(
DataSet
dataSet
)
|
Void
|
protected |
OnPropertyChanging |
(
PropertyChangedEventArgs
pcevent
)
|
Void
|
protected |
OnRemoveRelation |
(
DataRelation
relation
)
|
Void
|
public |
ReadXml |
(
Stream
stream
,
XmlReadMode
mode
)
|
XmlReadMode
|
public |
ReadXml |
(
TextReader
reader
,
XmlReadMode
mode
)
|
XmlReadMode
|
public |
ReadXml |
(
String
fileName
,
XmlReadMode
mode
)
|
XmlReadMode
|
public |
ReadXml |
(
Stream
stream
)
|
XmlReadMode
|
public |
ReadXml |
(
XmlReader
reader
)
|
XmlReadMode
|
public |
ReadXml |
(
TextReader
reader
)
|
XmlReadMode
|
public |
ReadXml |
(
XmlReader
reader
,
XmlReadMode
mode
)
|
XmlReadMode
|
public |
ReadXml |
(
String
fileName
)
|
XmlReadMode
|
public |
ReadXmlSchema |
(
XmlReader
reader
)
|
Void
|
public |
ReadXmlSchema |
(
Stream
stream
)
|
Void
|
public |
ReadXmlSchema |
(
String
fileName
)
|
Void
|
public |
ReadXmlSchema |
(
TextReader
reader
)
|
Void
|
protected |
ReadXmlSerializable |
(
XmlReader
reader
)
|
Void
|
public |
RejectChanges |
( )
|
Void
|
public |
Reset |
( )
|
Void
|
protected |
ShouldSerializeRelations |
( )
|
Boolean
|
protected |
ShouldSerializeTables |
( )
|
Boolean
|
public |
WriteXml |
(
XmlWriter
writer
)
|
Void
|
public |
WriteXml |
(
String
fileName
)
|
Void
|
public |
WriteXml |
(
Stream
stream
)
|
Void
|
public |
WriteXml |
(
TextWriter
writer
)
|
Void
|
public |
WriteXml |
(
XmlWriter
writer
,
XmlWriteMode
mode
)
|
Void
|
public |
WriteXml |
(
String
fileName
,
XmlWriteMode
mode
)
|
Void
|
public |
WriteXml |
(
Stream
stream
,
XmlWriteMode
mode
)
|
Void
|
public |
WriteXml |
(
TextWriter
writer
,
XmlWriteMode
mode
)
|
Void
|
public |
WriteXmlSchema |
(
Stream
stream
,
Converter`2
multipleTargetConverter
)
|
Void
|
public |
WriteXmlSchema |
(
String
fileName
)
|
Void
|
public |
WriteXmlSchema |
(
XmlWriter
writer
,
Converter`2
multipleTargetConverter
)
|
Void
|
public |
WriteXmlSchema |
(
Stream
stream
)
|
Void
|
public |
WriteXmlSchema |
(
TextWriter
writer
,
Converter`2
multipleTargetConverter
)
|
Void
|
public |
WriteXmlSchema |
(
XmlWriter
writer
)
|
Void
|
public |
WriteXmlSchema |
(
String
fileName
,
Converter`2
multipleTargetConverter
)
|
Void
|
public |
WriteXmlSchema |
(
TextWriter
writer
)
|
Void
|
|
The DataSet is an in-memory cache of data retrieved from a database, is a major component of the ADO.NET architecture. The DataSet consists of a collection of DataTable objects that you can relate to each other with DataRelation objects. You can also enforce data integrity in the DataSet by using the UniqueConstraint and ForeignKeyConstraint objects. For further details about working with DataSet objects, see Creating and Using DataSets.
While DataTable objects contain the data, the DataRelationCollection allows you to navigate though the table hierarchy. The tables are contained in a DataTableCollection accessed through the Tables property. When accessing DataTable objects, note that they are conditionally case-sensitive. For example, if one DataTable is named "mydatatable " and another is named "myDataTable ", a string used to search for one of the tables is regarded as case-sensitive. However, if "mydatatable " exists and "myDataTable " does not, the search string is regarded as case-insensitive. For more information about working with DataTable objects, see Creating a DataTable.
A DataSet reads and writes data and schema as XML documents. The data and schema can be transported across HTTP and used by any application, on any platform that is XML-enabled. 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 which infers and initializes a schema from the document.
In a typical multiple-tier implementation, the steps for creating and refreshing a DataSet, and in turn, updating the original data shouce would be to:
- Build and fill each DataTable in a DataSet with data from a data source using an SqlDataAdapter or OleDbDataAdapter.
- Change the data in individual DataTable objects by adding, updating, or deleting DataRow objects.
- Invoke the GetChanges method to create a second DataSet that features only the changes to the data.
- Check for errors in the second DataSet by examining its HasErrors property which informs you if any table in the set has errors.
- If errors are present, check the HasErrors property of each DataTable. If the DataTable contains errors, call the GetErrors method of the DataTable object to return an array of DataRow objects containing errors.
- On each DataRow, examine the RowError property for specific data. .
- Invoke the Merge method to merge the changes from the second DataSet into the first.
- Call the Update method of the SqlDataAdapter ( or OleDbDataAdapter ), passing the merged DataSet as an argument.
- Invoke the AcceptChanges on the DataSet. Alternatively, invoke RejectChanges to cancel the changes.
CAUTION: the DataSet stores data using the set of .NET Framework types. This is generally the most convenient representation for the user, but may cause problems when the back-end type is an SQL Server™ decimal data type. The .NET Framework decimal type allows a maximum of 28 significant digits, while the SQL Server™ decimal data type allows 38 significant digits. If an application attempts to fill a .NET Framework decimal data type with an SQL Server™ decimal data type, an exception is thrown and the fill operation terminates because data cached in the DataSet would lose the extra precision.
NOTE: the DataSet and DataTable objects inherit from MarshalByValueComponent, and support the ISerializable interface for remoting. These are the only ADO.NET objects that can be remoted.
The following example demonstrates using a DataAdapter to retrieve SQL Server™ data into a Dataset, then iterate thru and display the contents of the DataSet using simple foreach loops.
Show me
See Retrieving Data Using a DataSet for related information.
The below example demonstrates using ReadXml to load an XML file into a Dataset, then iterates thru and displays the contents of the DataSet using simple foreach loops.
Show me
See Retrieving XML Data Using a DataSet for related information.
DataTable DataRelation DataRow DataView ForeignKeyConstraint OleDbDataAdapter SqlDataAdapter UniqueConstraint
|
|