Code snippet for writing xml file from Dataset in vb.net

Code snippet for writing xml file from Dataset in vb.net

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