共用方式為


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

備註

Namespace此特性用於用 、 、 WriteXmlReadXmlSchemaWriteXmlSchema 方法來讀寫 XML 文件DataSetReadXml

XML 文件的命名空間用於讀取 DataSetXML 屬性與元素時的範圍。 例如,若 a DataSet 包含從命名空間為「myCompany」的文件讀取的結構,且嘗試只從不同命名空間的文件讀取資料,則任何與現有結構不符的資料都會被忽略。

適用於

另請參閱