- A CSV file - You can retrieve the rows to be archived into a dataset, a create a CSV file using the string builder and system.IO
Dim filename As String = 'your file path
Dim sro As New StreamWriter(filename)
Dim dr As DataRow
For Each dr In ds.Tables(0).Rows
Dim sb As New System.Text.StringBuilder
For ix As Integer = 0 To ds.Tables(0).Columns.Count - 1
sb.Append(dr.Item(ix))
If ix < ds.Tables(0).Columns.Count - 1 Then
sb.Append(",")
End If
Next
sro.WriteLine(sb.ToString)
Next
sro.Close()
- A XML file - Retrieve the rows to be archived into a dataset and use the dataset’s WriteXML method.
Dim filename as string = 'Your file path
ds.WriteXml(filename)
You can use the ReadXML method to retrieve the data from the XML file into a dataset.