You can use WriteXml method of the Dataset for saving the dataset data in xml format. And you can call ReadXml method for getting dataset from the xml file. In this article we will discuss about both methods.
Create xml file from a dataset
Private Sub WriteXML_fromDS() Dim Conn As New SqlClient.SqlConnection("Put here your Connection string") Dim StrQuery As String = "Your select query" Conn.Open() Dim ds As New DataSet Dim dadapter As New SqlClient.SqlDataAdapter("select * from sales ", Conn) dadapter.Fill(ds) ds.WriteXml("put xml file path with file name") Conn.Close() End Sub
Get dataset from a Xml file
In the following example we are creating a dataset from the specified xml file see this:
Private sub ReadXMLIntoDS() Dim ds as Dataset ds.readXml("xml fie path") End Sub