System.Data Namespace DataSet Class
Reads the XML schema into the DataSet.
1. Reads the XML schema from the specified Stream into the DataSet.
2. Reads the XML schema from the specified file into the DataSet.
3. Reads the XML schema from the specified TextReader into the DataSet.
4. Reads the XML schema from the specified XmlReader into the DataSet.
The following example illustrates use of the ReadXmlSchema method.
NOTE: This example uses one of the overloaded versions of ReadXmlSchema. For other examples that may be available, see the individual overload topics.
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 = "mySchema.xml";
// create a FileStream object with the file path and name.
System.IO.FileStream myFileStream = new System.IO.FileStream
( filename,System.IO.FileMode.Open );
// create a new XmlTextReader object with the FileStream.
System.Xml.XmlTextReader myXmlTextReader =
new System.Xml.XmlTextReader ( myFileStream );
// Read the schema into the DataSet and close the reader.
thisDataSet.ReadXmlSchema ( myXmlTextReader );
myXmlTextReader.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 = "mySchema.xml"
' Create a FileStream object with the file path and name.
Dim myFileStream As New System.IO.FileStream _
( filename, System.IO.FileMode.Open )
' Create a new XmlTextReader object with the FileStream.
Dim myXmlTextReader As New System.Xml.XmlTextReader _
( myFileStream )
' Read the schema into the DataSet and close the reader.
thisDataSet.ReadXmlSchema ( myXmlTextReader )
myXmlTextReader.Close ( )
End Sub |
|
C# |
VB |
DataSet Members