Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DataSet.Namespace Property

Gets or sets the namespace of the DataSet.

[Visual Basic]
Public Property Namespace As String
[C#]
public string Namespace {get; set;}
[C++]
public: __property String* get_Namespace();
public: __property void set_Namespace(String*);
[JScript]
public function get Namespace() : String;
public function set Namespace(String);

Property Value

The namespace of the DataSet.

Exceptions

Exception Type Condition
ArgumentException The namespace already has data.

Remarks

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, if a DataSet contains a schema that was read from a document with the namespace "myCompany," and an attempt is made to read data only from a document with a different namespace, any data that does not correspond to the existing schema will be ignored.

Example

[Visual Basic, C#, C++] The following example sets the Prefix before calling the ReadXml method.

[Visual Basic] 
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#] 
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);
}

[C++] 
private:
 void ReadData(DataSet* thisDataSet){
    thisDataSet->Namespace = S"CorporationA";
    thisDataSet->Prefix = S"DivisionA";
    // Read schema and data.
    String* filename = S"CorporationA_Schema.xml";
    thisDataSet->ReadXmlSchema(filename);
    filename = S"DivisionA_Report.xml";
    thisDataSet->ReadXml(filename);
 }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

DataSet Class | DataSet Members | System.Data Namespace | Prefix

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft