惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
S
Securelist
D
Docker
The Register - Security
The Register - Security
GbyAI
GbyAI
Recorded Future
Recorded Future
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
罗磊的独立博客
博客园 - 【当耐特】
F
Full Disclosure
WordPress大学
WordPress大学
腾讯CDC
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
SecWiki News
SecWiki News
L
Lohrmann on Cybersecurity
I
InfoQ
MyScale Blog
MyScale Blog
量子位
Cyberwarzone
Cyberwarzone
博客园 - 三生石上(FineUI控件)
The Hacker News
The Hacker News
F
Fortinet All Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
博客园_首页
H
Help Net Security
K
Kaspersky official blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Webroot Blog
Webroot Blog
Blog — PlanetScale
Blog — PlanetScale
V
Vulnerabilities – Threatpost
Y
Y Combinator Blog
The Cloudflare Blog
P
Proofpoint News Feed
V
Visual Studio Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tailwind CSS Blog
爱范儿
爱范儿
P
Privacy International News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
B
Blog RSS Feed

博客园 - 我是程序员

Kubernetes集群安全概述 EventStore .NET API Client在使用线程池线程同步写入Event导致EventStore连接中断的问题研究 Silverlight下实现Windows8风格的进度条 如何确保Silverlight按照区域设定自动加载对应区域的资源 查看进程的启动参数 (转) 如何在Access2007中打开加密的Access2003数据库 在WPF中如何注册热键 业务流程不是需求(ZT) 如何取消ActiveReport的打印任务 开源license总结(转) 利用Eclipse调试JSP XML文件的DOCTYPE定义(转) - 我是程序员 - 博客园 如何定制Acegi验证框架的验证错误信息 别让Hibernate偷走了您的身份(转) Firefox下强制页面缓存失效的设置方法 - 我是程序员 - 博客园 有关Struts标签<html:cancel>使用的一点提示 - 我是程序员 - 博客园 Struts Commons-validator的validation.xml验证文件的配置指南(转) - 我是程序员 - 博客园 大型Web2.0站点构建技术初探(转) 面向对象分析设计的六十一条经验原则(转贴)
如何将文本文件读入到DataSet中
我是程序员 · 2008-03-17 · via 博客园 - 我是程序员

Posted on 2008-03-17 16:25  我是程序员  阅读(763)  评论(0)    收藏  举报

需要注意的是文件的第一行被认为是Column信息

//创建数据库连接System.Data.OleDb.OleDbConnection con = new System.Data.OleDb.OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=文件所在目录;Extended Properties=""Text;HDR=yes;FMT=Delimited""");

//打开数据库连接
con.Open();

//创建查询命令
System.Data.OleDb.OleDbCommand com = new System.Data.OleDb.OleDbCommand("Select * From 文件名称.csv");

//设置连接
com.Connection = con;

//创建Adapter
System.Data.OleDb.OleDbDataAdapter adapter = new System.Data.OleDb.OleDbDataAdapter(com);

//创建DataSet
DataSet ds = new DataSet();

//执行查询
adapter.Fill(ds);

刷新页面返回顶部