DataSet.ReadXmlSchema メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
XML スキーマを DataSetに読み取ります。
オーバーロード
| 名前 | 説明 |
|---|---|
| ReadXmlSchema(Stream) | |
| ReadXmlSchema(TextReader) |
指定した TextReader から XML スキーマを DataSetに読み取ります。 |
| ReadXmlSchema(String) |
指定したファイルから XML スキーマを DataSetに読み取ります。 |
| ReadXmlSchema(XmlReader) |
ReadXmlSchema(Stream)
public:
void ReadXmlSchema(System::IO::Stream ^ stream);
public void ReadXmlSchema(System.IO.Stream stream);
member this.ReadXmlSchema : System.IO.Stream -> unit
Public Sub ReadXmlSchema (stream As Stream)
パラメーター
例
次の例では、XML スキーマを読み取る FileStream オブジェクトを作成し、そのオブジェクトを使用して ReadXmlSchema メソッドを呼び出します。
private void ReadSchemaFromFileStream(DataSet thisDataSet)
{
// Set the file path and name.
// Modify this for your purposes.
string filename="Schema.xml";
// Create the FileStream object with the file name,
// and set to open the file.
System.IO.FileStream stream =
new System.IO.FileStream(filename,System.IO.FileMode.Open);
// Read the schema into the DataSet.
thisDataSet.ReadXmlSchema(stream);
// Close the FileStream.
stream.Close();
}
Private Sub ReadSchemaFromFileStream(thisDataSet As DataSet)
' Set the file path and name. Modify this for your purposes.
Dim filename As String = "Schema.xml"
' Create the FileStream object with the file name,
' and set to open the file
Dim stream As New System.IO.FileStream _
(filename, System.IO.FileMode.Open)
' Read the schema into the DataSet.
thisDataSet.ReadXmlSchema(stream)
' Close the FileStream.
stream.Close()
End Sub
注釈
ReadXmlSchema メソッドを使用して、DataSetのスキーマを作成します。 スキーマには、テーブル、リレーションシップ、および制約の定義が含まれます。 XML ドキュメントにスキーマを書き込むには、 WriteXmlSchema メソッドを使用します。
XML スキーマは、XSD 標準を使用して記述されます。
Note
msdata:DataType 型と xs:type 型が一致しない場合、データの破損が発生する可能性があります。 例外はスローされません。
ReadXmlSchema メソッドは、通常、DataSetを満たすために使用されるReadXml メソッドを呼び出す前に呼び出されます。
Stream クラスから派生するクラスには、BufferedStream、FileStream、MemoryStream、およびNetworkStreamが含まれます。
Note
DataSetのスキーマに同じ名前の要素が含まれているが、同じ名前空間に異なる型が含まれている場合、ReadXmlSchemaを使用してスキーマをDataSetに読み込もうとすると、例外がスローされます。 .NET Framework バージョン 1.0 を使用している場合、この例外は発生しません。
こちらもご覧ください
適用対象
ReadXmlSchema(TextReader)
指定した TextReader から XML スキーマを DataSetに読み取ります。
public:
void ReadXmlSchema(System::IO::TextReader ^ reader);
public void ReadXmlSchema(System.IO.TextReader reader);
member this.ReadXmlSchema : System.IO.TextReader -> unit
Public Sub ReadXmlSchema (reader As TextReader)
パラメーター
- reader
- TextReader
読み取り元の TextReader 。
例
次の例では、スキーマを読み取る StreamReader オブジェクトを作成し、そのオブジェクトを使用して ReadXmlSchema メソッドを呼び出します。
private void ReadSchemaFromStreamReader()
{
// Create the DataSet to read the schema into.
DataSet thisDataSet = new DataSet();
// Set the file path and name. Modify this for your purposes.
string filename="Schema.xml";
// Create a StreamReader object with the file path and name.
System.IO.StreamReader readStream =
new System.IO.StreamReader(filename);
// Invoke the ReadXmlSchema method with the StreamReader object.
thisDataSet.ReadXmlSchema(readStream);
// Close the StreamReader
readStream.Close();
}
Private Sub ReadSchemaFromStreamReader()
' Create the DataSet to read the schema into.
Dim thisDataSet As New DataSet()
' Set the file path and name. Modify this for your purposes.
Dim filename As String = "Schema.xml"
' Create a StreamReader object with the file path and name.
Dim readStream As New System.IO.StreamReader(filename)
' Invoke the ReadXmlSchema method with the StreamReader object.
thisDataSet.ReadXmlSchema(readStream)
' Close the StreamReader
readStream.Close()
End Sub
注釈
ReadXmlSchema メソッドを使用して、DataSetのスキーマを作成します。 スキーマには、テーブル、リレーションシップ、および制約の定義が含まれます。 XML ドキュメントにスキーマを書き込むには、 WriteXmlSchema メソッドを使用します。
XML スキーマは、XSD 標準を使用して記述されます。
Note
msdata:DataType 型と xs:type 型が一致しない場合、データの破損が発生する可能性があります。 例外はスローされません。
ReadXmlSchema メソッドは、通常、DataSetを満たすために使用されるReadXml メソッドを呼び出す前に呼び出されます。
TextReader クラスから継承するクラスには、StreamReaderクラスとStringReader クラスが含まれます。
Note
DataSetのスキーマに同じ名前の要素が含まれているが、同じ名前空間に異なる型が含まれている場合、ReadXmlSchemaを使用してスキーマをDataSetに読み込もうとすると、例外がスローされます。 .NET Framework バージョン 1.0 を使用している場合、この例外は発生しません。
こちらもご覧ください
適用対象
ReadXmlSchema(String)
指定したファイルから XML スキーマを DataSetに読み取ります。
public:
void ReadXmlSchema(System::String ^ fileName);
public void ReadXmlSchema(string fileName);
member this.ReadXmlSchema : string -> unit
Public Sub ReadXmlSchema (fileName As String)
パラメーター
- fileName
- String
読み取り元のファイル名 (パスを含む)。
例外
FileIOPermission が Read に設定されていません。
例
private void ReadSchemaFromFile(){
// Create the DataSet to read the schema into.
DataSet thisDataSet = new DataSet();
// Set the file path and name. Modify this for your purposes.
string filename="Schema.xml";
// Invoke the ReadXmlSchema method with the file name.
thisDataSet.ReadXmlSchema(filename);
}
Private Sub ReadSchemaFromFile()
' Create the DataSet to read the schema into.
Dim thisDataSet As New DataSet()
' Set the file path and name. Modify this for your purposes.
Dim filename As String = "Schema.xml"
' Invoke the ReadXmlSchema method with the file name.
thisDataSet.ReadXmlSchema(filename)
End Sub
注釈
ReadXmlSchema メソッドを使用して、DataSetのスキーマを作成します。 スキーマには、テーブル、リレーションシップ、および制約の定義が含まれます。 XML ドキュメントにスキーマを書き込むには、 WriteXmlSchema メソッドを使用します。
XML スキーマは、XSD 標準を使用して記述されます。
Note
msdata:DataType 型と xs:type 型が一致しない場合、データの破損が発生する可能性があります。 例外はスローされません。
ReadXmlSchema メソッドは、通常、DataSetを満たすために使用されるReadXml メソッドを呼び出す前に呼び出されます。
Note
DataSetのスキーマに同じ名前の異なる型の要素が同じ名前空間に含まれている場合、ReadXmlSchemaを使用してスキーマをDataSetに読み込もうとすると、例外がスローされます。 .NET Framework バージョン 1.0 を使用している場合、この例外は発生しません。
こちらもご覧ください
適用対象
ReadXmlSchema(XmlReader)
public:
void ReadXmlSchema(System::Xml::XmlReader ^ reader);
public void ReadXmlSchema(System.Xml.XmlReader reader);
member this.ReadXmlSchema : System.Xml.XmlReader -> unit
Public Sub ReadXmlSchema (reader As XmlReader)
パラメーター
例
次の例では、新しい DataSet と System.IO.FileStream オブジェクトを作成します。 ファイル パスとファイル名で作成されたFileStream オブジェクトは、ReadXmlSchema メソッドに引数として渡されるSystem.Xml.XmlTextReaderを作成するために使用されます。
private void ReadSchemaFromXmlTextReader()
{
// Create the DataSet to read the schema into.
DataSet thisDataSet = new DataSet();
// Set the file path and name. Modify this for your purposes.
string filename="Schema.xml";
// Create a FileStream object with the file path and name.
System.IO.FileStream stream = new System.IO.FileStream
(filename,System.IO.FileMode.Open);
// Create a new XmlTextReader object with the FileStream.
System.Xml.XmlTextReader xmlReader=
new System.Xml.XmlTextReader(stream);
// Read the schema into the DataSet and close the reader.
thisDataSet.ReadXmlSchema(xmlReader);
xmlReader.Close();
}
Private Sub ReadSchemaFromXmlTextReader()
' Create the DataSet to read the schema into.
Dim thisDataSet As New DataSet()
' Set the file path and name. Modify this for your purposes.
Dim filename As String = "Schema.xml"
' Create a FileStream object with the file path and name.
Dim stream As New System.IO.FileStream _
(filename, System.IO.FileMode.Open)
' Create a new XmlTextReader object with the FileStream.
Dim xmlReader As New System.Xml.XmlTextReader(stream)
' Read the schema into the DataSet and close the reader.
thisDataSet.ReadXmlSchema(xmlReader)
xmlReader.Close()
End Sub
注釈
ReadXmlSchema メソッドを使用して、DataSetのスキーマを作成します。 スキーマには、テーブル、リレーションシップ、および制約の定義が含まれます。
XML スキーマは、XSD 標準を使用して記述されます。
Note
msdata:DataType 型と xs:type 型が一致しない場合、データの破損が発生する可能性があります。 例外はスローされません。
ReadXmlSchema メソッドは、通常、DataSetを満たすために使用されるReadXml メソッドを呼び出す前に呼び出されます。
System.Xml.XmlReader クラスは抽象クラスです。
XmlReaderから継承するクラスは、System.Xml.XmlTextReader クラスです。
Note
DataSetのスキーマに同じ名前の要素が含まれているが、同じ名前空間に異なる型が含まれている場合、ReadXmlSchemaを使用してスキーマをDataSetに読み込もうとすると、例外がスローされます。 .NET Framework バージョン 1.0 を使用している場合、この例外は発生しません。