Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to Export to CSV file from DataSet?

How to Export to CSV file from DataSet?

Scheduled Pinned Locked Moved C#
csharpdatabasehelptutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    HyVong
    wrote on last edited by
    #1

    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*

    N M 2 Replies Last reply
    0
    • H 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*

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • H 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*

        M Offline
        M Offline
        Michael P Butler
        wrote on last edited by
        #3

        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 [^]

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups