System.Data Namespace DataSet Class
Sets or retrieves the namespace of the DataSet.
Script |
DataSet.Namespace [ = strName ] |
strName |
String specifying the namespace of the DataSet. |
The property is read/write with no default value.
Exception Type |
Condition |
ArgumentException |
Occurs when the namespace already has data. |
The Namespace property is used when reading and writing an XML document into the DataSet using the ReadXml, WriteXml, ReadXmlSchema, or WriteXmlSchema methods.
The namespace of an XML document is used to scope XML attributes and elements when read into a DataSet. For example, a DataSet contains a schema read from a document with the namespace "myCompany
", and an attempt is made to read data ( with the ReadXml method ) from a document with the namespace "theirCompany
". Any data that does not correspond to the existing schema will be ignored.
The following example sets the Prefix before calling the ReadXml method.
private void ReadData ( DataSet thisDataSet ) {
thisDataSet.Namespace = "CorporationA";
thisDataSet.Prefix = "DivisionA";
// read schema and data.
string filename = "CorporationA_Schema.xml";
thisDataSet.ReadXmlSchema ( filename );
filename = "DivisionA_Report.xml";
thisDataSet.ReadXml ( filename );
}
Private Sub ReadData ( thisDataSet As DataSet )
thisDataSet.Namespace = "CorporationA"
thisDataSet.Prefix = "DivisionA"
' Read schema and data.
Dim filename As String = "CorporationA_Schema.xml"
thisDataSet.ReadXmlSchema ( filename )
filename = "DivisionA_Report.xml"
thisDataSet.ReadXml ( filename )
End Sub |
|
C# |
VB |
DataSet Members Prefix