Using xml in a data set (ADO.NET)
-
Upload
alfred-jett-grandeza -
Category
Technology
-
view
425 -
download
0
Transcript of Using xml in a data set (ADO.NET)
![Page 1: Using xml in a data set (ADO.NET)](https://reader036.fdocuments.in/reader036/viewer/2022082921/55599af7d8b42a14638b5757/html5/thumbnails/1.jpg)
Using XML in a DataSet (ADO.NET)
Ringo Ray H Piedraverde(Jr. Programmer)
![Page 2: Using xml in a data set (ADO.NET)](https://reader036.fdocuments.in/reader036/viewer/2022082921/55599af7d8b42a14638b5757/html5/thumbnails/2.jpg)
Topics
• Writing DataSet Contents as XML Data (ADO.NET)
• Loading a DataSet from XML (ADO.NET)
![Page 3: Using xml in a data set (ADO.NET)](https://reader036.fdocuments.in/reader036/viewer/2022082921/55599af7d8b42a14638b5757/html5/thumbnails/3.jpg)
Writing DataSet Contents as XML Data (ADO.NET)
• WriteScheme Method– Writes the current contents of the DataSet as XML
data with the relational structure as inline XML Schema.
• WriteXml method– Using this method you can write the Dataset to a
file, stream, or XmlWriter.
![Page 4: Using xml in a data set (ADO.NET)](https://reader036.fdocuments.in/reader036/viewer/2022082921/55599af7d8b42a14638b5757/html5/thumbnails/4.jpg)
Code Snippet
Dim mds As DataSet = mds.tables(“tblUser”)
mUserDS.WriteXml(“User.xml", XmlWriteMode.WriteSchema)
![Page 5: Using xml in a data set (ADO.NET)](https://reader036.fdocuments.in/reader036/viewer/2022082921/55599af7d8b42a14638b5757/html5/thumbnails/5.jpg)
Xml output
![Page 6: Using xml in a data set (ADO.NET)](https://reader036.fdocuments.in/reader036/viewer/2022082921/55599af7d8b42a14638b5757/html5/thumbnails/6.jpg)
Loading a DataSet from XML (ADO.NET)
• To fill a DataSet with data from XML, use the ReadXml method of the DataSet object. The ReadXml method reads from a file, a stream, or an XmlReader, and takes as arguments the source of the XML.
• The ReadXml method reads the contents of the XML stream or document and loads the DataSet with data. It will also create the relational schema of the DataSet depending on the XmlReadMode specified and whether or not a relational schema already exists.
![Page 7: Using xml in a data set (ADO.NET)](https://reader036.fdocuments.in/reader036/viewer/2022082921/55599af7d8b42a14638b5757/html5/thumbnails/7.jpg)
Code snippet
Dim m_Ds as Dataset
Public sub ReadXML()
m_User.ReadXml(“User.xml", XmlReadMode.ReadSchema)
End Sub
![Page 8: Using xml in a data set (ADO.NET)](https://reader036.fdocuments.in/reader036/viewer/2022082921/55599af7d8b42a14638b5757/html5/thumbnails/8.jpg)
Reading Output
![Page 9: Using xml in a data set (ADO.NET)](https://reader036.fdocuments.in/reader036/viewer/2022082921/55599af7d8b42a14638b5757/html5/thumbnails/9.jpg)
• End