DataSet.Namespace 屬性

定義

取得或設定 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, set
Public 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

備註

使用、、 或 方法將 XML 檔案DataSet讀取與寫入 至時, 會Namespace使用 ReadXml屬性。WriteXmlSchemaReadXmlSchemaWriteXml

XML 檔案的命名空間是用來在讀取至 DataSet時設定 XML 屬性和元素的範圍。 例如,如果 DataSet 包含從命名空間為 「myCompany」 的檔案讀取的架構,而且嘗試只從具有不同命名空間的檔讀取數據,則會忽略未對應至現有架構的任何數據。

適用於

另請參閱