How to Export to CSV file from DataSet?
-
Hi everyone, I'm trying to export into a csv file from the dataset. But i'm not using Button. I'm asking the user to check on the check box if they want to export the file. If they checked that checkbox, as i go through the form and grab data through my sql statement (and the data are now in the dataset, with two table, but i only want to export one table), at the end i would like to send those data to the csv file. And i have done some research but couldn't find much on what I'm doing. Does any one have any C# sample code links or give some suggestion in the coding, i'll be very appriciated. This is totally new to me, so i'm asking for everyone's help. Thanks in advance for your time. Cheers!:-D *HyVong*
-
Hi everyone, I'm trying to export into a csv file from the dataset. But i'm not using Button. I'm asking the user to check on the check box if they want to export the file. If they checked that checkbox, as i go through the form and grab data through my sql statement (and the data are now in the dataset, with two table, but i only want to export one table), at the end i would like to send those data to the csv file. And i have done some research but couldn't find much on what I'm doing. Does any one have any C# sample code links or give some suggestion in the coding, i'll be very appriciated. This is totally new to me, so i'm asking for everyone's help. Thanks in advance for your time. Cheers!:-D *HyVong*
One way is to use XSLT to transform the dataset xml into a csv format. You could of course just iterate through the dataset and write to a file yourself.
-
Hi everyone, I'm trying to export into a csv file from the dataset. But i'm not using Button. I'm asking the user to check on the check box if they want to export the file. If they checked that checkbox, as i go through the form and grab data through my sql statement (and the data are now in the dataset, with two table, but i only want to export one table), at the end i would like to send those data to the csv file. And i have done some research but couldn't find much on what I'm doing. Does any one have any C# sample code links or give some suggestion in the coding, i'll be very appriciated. This is totally new to me, so i'm asking for everyone's help. Thanks in advance for your time. Cheers!:-D *HyVong*
Its VB.NET code but this example illustrates how to do it DataTable2CSV - Saving a DataTable to a CSV file[^] There should be no problem converting the code to C# Michael CP Blog [^]