'* This routine is used to convert a DataView to a DataSet Public Shared Function DataViewToDataSet(ByVal dvToConvert As DataView) As DataSet ' Variables Dim dtRtn As New DataTable() Dim dsRtn As New DataSet() Dim drRtn As DataRow Dim nC1%, nC2% ' Assign Value / Stucture dtRtn = dvToConvert.Table.Copy ' Clear All Data dtRtn.Rows.Clear() ' Loop DataView For nC1 = 0 To (dvToConvert.Count - 1) ' Derive New Row drRtn = dtRtn.NewRow() ' Convert Data For nC2 = 0 To (dvToConvert.Table.Columns.Count - 1) drRtn(nC2) = dvToConvert(nC1)(nC2) Next dtRtn.Rows.Add(drRtn) ' Free Row drRtn = Nothing Next ' Append Table to DataSet dsRtn.Tables.Add(dtRtn) ' Return Data Return dsRtn End FunctionYou may could use the above code to help automate the process... In other words filter the view one record at a time and then convert the view to a DataSet and export it. Also, if you don't want to have to create a file for each record you can use to following code export to a memory stream which then converts to a string.
' Stream Values Dim msMem As New System.IO.MemoryStream() ' Export dsToExport.WriteXml(msMem, XmlWriteMode.WriteSchema) ' Variables Dim oDcod As Decoder Dim aChars() As Char Dim sVar$ ' Resize Array ReDim aChars(CInt(msMem.Length)) ' Setup Decoder oDcod = Encoding.UTF8.GetDecoder() oDcod.GetChars(msMem.GetBuffer(), 0, CInt(msMem.Length), aChars, 0) ' Convert to String sVar = New String(aChars) ' Free Memory oDcod = Nothing aChars = Nothing msMem.Close() msMem = NothingHope that helps...