Search Chirayu Software Solutions Blog

Saturday, September 28, 2013

convert dataset into csv file

Code Snippet
Dim str As New StringBuilder
For Each dr As DataRow In Me.NorthwindDataSet.Customers
     For Each field As Object In dr.ItemArray
     str.Append(field.ToString & ",")
     Next
     str.Replace(",", vbNewLine, str.Length - 1, 1)
Next

Try
     My.Computer.FileSystem.WriteAllText("C:\temp\testcsv.csv", str.ToString, False)
Catch ex As Exception
     MessageBox.Show("Write Error")

End Try
Post a Comment