DataSet.Namespace 属性  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置 DataSet 的命名空间。
public:
 property System::String ^ Namespace { System::String ^ get(); void set(System::String ^ value); };public string Namespace { get; set; }[System.Data.DataSysDescription("DataSetNamespaceDescr")]
public string Namespace { get; set; }member this.Namespace : string with get, set[<System.Data.DataSysDescription("DataSetNamespaceDescr")>]
member this.Namespace : string with get, setPublic Property Namespace As String属性值
DataSet 的命名空间。
- 属性
例外
该命名空间已有数据。
示例
以下示例在调用 ReadXml 方法之前设置 Prefix 。
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
注解
使用 NamespaceReadXml、WriteXml、 ReadXmlSchema或 WriteXmlSchema 方法将 XML 文档读取和写入 时DataSet,使用 属性。
XML 文档的命名空间用于在读入 DataSet时限定 XML 属性和元素的范围。 例如,如果 DataSet 包含从命名空间为“myCompany”的文档读取的架构,并且尝试仅从具有不同命名空间的文档读取数据,则会忽略与现有架构不对应的任何数据。