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

推荐订阅源

WordPress大学
WordPress大学
V
Visual Studio Blog
P
Privacy International News Feed
月光博客
月光博客
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
Lohrmann on Cybersecurity
N
News and Events Feed by Topic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Apple Machine Learning Research
Apple Machine Learning Research
阮一峰的网络日志
阮一峰的网络日志
Webroot Blog
Webroot Blog
T
Threatpost
宝玉的分享
宝玉的分享
The Last Watchdog
The Last Watchdog
小众软件
小众软件
L
LINUX DO - 最新话题
C
Cisco Blogs
T
Troy Hunt's Blog
Schneier on Security
Schneier on Security
酷 壳 – CoolShell
酷 壳 – CoolShell
www.infosecurity-magazine.com
www.infosecurity-magazine.com
雷峰网
雷峰网
G
GRAHAM CLULEY
有赞技术团队
有赞技术团队
Know Your Adversary
Know Your Adversary
博客园 - 叶小钗
罗磊的独立博客
V
V2EX
博客园 - Franky
P
Proofpoint News Feed
SecWiki News
SecWiki News
腾讯CDC
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Jina AI
Jina AI
博客园 - 三生石上(FineUI控件)
S
Secure Thoughts
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
PCI Perspectives
PCI Perspectives
V2EX - 技术
V2EX - 技术
Google DeepMind News
Google DeepMind News
Last Week in AI
Last Week in AI
aimingoo的专栏
aimingoo的专栏
Cisco Talos Blog
Cisco Talos Blog
N
News and Events Feed by Topic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
SegmentFault 最新的问题

博客园 - 没有空气

修改win7电脑中所有文件的默认查看方式 转:Google推出免费DNS服务,首选首选8.8.8.8 备选8.8.4.4 无法在Web服务器上启动调试。您不具备调试此应用程序的权限,此项目的URL位于Internet区域 Oracle错误:"ORA-00988: 口令缺失或无效"解决 Oracle中用户用as sysdba可以登录,但normal登录不了 oracle 视图上创建触发器,发生“无法在视图上创建此类型的触发器”错误 异形孔向导用不了的解决办法(转) 给word 2003打补丁以适应2007文档格式 C#编程生成的Word2007版本的文件如何兼容Word2003?(通过代码将docx文件转存为doc文件) 原:Oracle 和 SqlServer下获取主外键表名字段名约束名的语句 sqlserver与oracle case when else ,isnull语法差别 DDL、DML、DCL Hashtable 使用GetEnumerator() 时发生 System.InvalidOperationException类型错误 npkcrypt 服务启动失败导致 Oracle11g TNSListener服务开机自动启动不了 WORD"对话框打开时命令无法执行"的解决方法 Nero刻录时报"QueryDosDevice Failed"错误 关于cidaemon.exe进程CUP占用率高的解决办法 "找不到可安装的 ISAM” 和"创建文件流失败" 求每个分组里面的最大值对应的记录的sql语句
取Excel表的字段名字
没有空气 · 2007-10-08 · via 博客园 - 没有空气

 前提是Excel第一行是字段名.
先看看这里,学习一下
 http://www.connectionstrings.com/?carrier=excel2007
含字段名的,要用HDR=Yes; 这时

注意Extended Properties="Excel 12.0;HDR=YES"中加了引号了,在c#中用\"表示引号

这样再运行就能正常取字段名了,刚才一直是乱码.

 1 DataSet   ds=new   DataSet();   
 2             string   strCon,strCmm;   
 3                 strCon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+workdir+";Extended Properties=\"Excel 8.0;HDR=Yes;\"";   //"HDR=Yes;" indicates that the first row contains columnnames, not data. "HDR=No;" indicates the opposite.   
 4             strCmm="select top 1 * from [Sheet1$]";   
 5             OleDbConnection   oleCnn=new   OleDbConnection(strCon);   
 6             OleDbCommand   oleCmm=new   OleDbCommand(strCmm,oleCnn);   
 7             try
 8             {
 9                 OleDbDataAdapter   oleDa=new   OleDbDataAdapter(oleCmm);  
10                 oleDa.Fill(ds,"test"); 
11             }
12             catch(System.Exception ex)
13             {
14                 string error=ex.Message;
15             }            
16             for(int i=0;i<ds.Tables[0].Columns.Count;i++)
17             {
18                 listBox1.Items.Add(ds.Tables[0].Columns[i]);
19             }

posted on 2007-10-08 12:04  没有空气  阅读(754)  评论()    收藏  举报