This documentation is archived and is not being maintained.

DataSet.Namespace Property

Gets or sets the namespace of the DataSet.

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

Property Value

The namespace of the DataSet.


Exception Type Condition
ArgumentException 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, 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.


[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"
    filename = "DivisionA_Report.xml"
End Sub

private void ReadData(DataSet thisDataSet){
   thisDataSet.Namespace = "CorporationA";
   thisDataSet.Prefix = "DivisionA";
   // Read schema and data.
   string filename = "CorporationA_Schema.xml";
   filename = "DivisionA_Report.xml";

 void ReadData(DataSet* thisDataSet){
    thisDataSet->Namespace = S"CorporationA";
    thisDataSet->Prefix = S"DivisionA";
    // Read schema and data.
    String* filename = S"CorporationA_Schema.xml";
    filename = S"DivisionA_Report.xml";

[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.


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