将数据表映射到datagridview [英] map Datatable to datagridview

查看:79
本文介绍了将数据表映射到datagridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何告诉DataGridView不要使用Excel数据源从数据表的第一行创建列标题?

解决方案

< blockquote>根据您将数据带入DataGridView的方式,您可能会使用HDR = NO在连接字符串中指定它。



如果您使用普通的* .xlsx文件,那么您的连接字符串将如下所示:



Provider = Microsoft.ACE.OLEDB.12.0; Data Source = c:\ myFolder \ myExcel2007file.xlsx;

扩展属性=Excel 12.0 Xml; HDR =否



以上的其他变体显示在connectionstrings.com。


感谢您的回复traciray。



实际上我已经在我的连接字符串中指定了HDR = No但仍然将我的第一个dataTables行作为列标题。





在我的连接字符串IMEX中还有一个参数设置为2.当我改为1时,它工作为我

How do I tell a DataGridView NOT to create column headers from the
first row of a data table using an Excel datasource?

解决方案

Depending on how you''re bringing the data into your DataGridView, you would probably specify it in your connection string using "HDR=NO".

If you''re using a normal *.xlsx file, then your connection string would look something like the one below:

"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;
Extended Properties="Excel 12.0 Xml;HDR=NO";"

Other variations of the above are shown at connectionstrings.com.


Thanks for your Reply traciray.

Actually i had specified that HDR=No in my connection string but still it was taking my 1st dataTables row as column header.


There was also one more parameter in my connection string IMEX which was set to 2. this when i changed to 1 it worked for me.


这篇关于将数据表映射到datagridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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