使用C#将8个Lakhs记录导出到csv [英] Export 8 Lakhs of records to csv using C#

查看:62
本文介绍了使用C#将8个Lakhs记录导出到csv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

任何人都可以提供一步一步的程序来连接数据库并将表格数据导出到.csv文件

提前谢谢。

问候,

Prakash

Hi all
Could any one provide step by step procedure to connect to database and export table data to .csv file
Thanks in advance.
Regards,
Prakash

推荐答案

打开你的CSV文件进行写作。

创建并打开一个数据库连接。

创建一个数据库查询命令并给它连接使用。

运行你的查询,可能使用DataReader。

Parse每个记录并将每个字段格式化为字符串。

将CSV行写入文件。

下一条记录,重复直到没有更多记录。

关闭数据库连接

关闭文件。



请记住,你得到的答案质量直接取决于质量你问的问题。
Open your CSV file for writing.
Create and open a database connection.
Create a database query command and give it the connection to use.
Run your query, probably using a DataReader.
Parse each record and format each field as a string.
Write your CSV line to the file.
Next record, repeat until there are no more records.
Close your database connection
Close your file.

Remember, the quality of the answer you get is directly dictated by the quality of the question you ask.


这篇关于使用C#将8个Lakhs记录导出到csv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆