System.Data Namespace DataSet Class
Reads the XML schema from the specified TextReader into the DataSet.
[ VB ]
Overloads Public Sub ReadXmlSchema ( _
ByVal reader As TextReader _
)
[ C# ]
public void ReadXmlSchema (
TextReader reader
);
[ C++ ]
public: void ReadXmlSchema (
TextReader* reader
);
[ JScript ]
public function ReadXmlSchema (
reader : TextReader
);
- reader
- The TextReader from which to read.
Use the ReadXmlSchema method to create the schema for a DataSet. The schema includes table, relation, and constraint definitions. To write a schema to an XML document, use the WriteXmlSchema method.
The XML schema is written using the XSD standard.
The ReadXmlSchema method is generally invoked before invoking the ReadXml method which is used to fill the DataSet.
Classes that inherit from the TextReader class include the StreamReader and StringReader classes.
The following shows an example of using this version of 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 = "mySchema.xml";
// create a StreamReader object with the file path and name.
System.IO.StreamReader myStreamReader = new System.IO.StreamReader ( filename );
// invoke the ReadXmlSchema method with the StreamReader object.
thisDataSet.ReadXmlSchema ( myStreamReader );
// close the StreamReader
myStreamReader.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 = "mySchema.xml"
' Create a StreamReader object with the file path and name.
Dim myStreamReader As New System.IO.StreamReader ( filename )
' invoke the ReadXmlSchema method with the StreamReader object.
thisDataSet.ReadXmlSchema ( myStreamReader )
' Close the StreamReader
myStreamReader.Close ( )
End Sub |
|
C# |
VB |
DataSet Members DataSet.ReadXmlSchema Overload List ReadXml WriteXml WriteXmlSchema