How to efficiently write to file from SQL datareader in c#?

前端 未结 7 1247
隐瞒了意图╮
隐瞒了意图╮ 2020-12-15 00:14

I have a remote sql connection in C# that needs to execute a query and save its results to the users\'s local hard disk. There is a fairly large amount of data this thing ca

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-15 00:52

    I used .CSV to export data from database by DataReader. in my project i read datareader and create .CSV file manualy. in a loop i read datareader and for every rows i append cell value to result string. for separate columns i use "," and for separate rows i use "\n". finally i saved result string as result.csv.

    I suggest this high performance extension. i tested it and quickly export 600,000 rows as .CSV .

提交回复
热议问题