OleDbDataAdapter未填充所有行 [英] OleDbDataAdapter not filling all of the rows
问题描述
嘿,我正在使用DataAdapter读取Excel文件,并用该数据填充数据表.
Hey I am using the DataAdapter to read an excel file and fill a Data Table with that data.
这是我的查询和连接字符串.
Here is my query and connection string.
private string Query = "SELECT * FROM Sheet1";
private string ConnectString = "Provider=Microsoft.ACE.OLEDB.12.0;"
+ "Data Source=\"" + Location + "\";"
+ "Extended Properties=\"Excel 12.0 Xml;HDR=YES\"";
OleDbDataAdapter DBAddapter = new OleDbDataAdapter(Query, ConnectString);
DataTable DBTable = new DataTable();
DBAddapter.Fill(DBTable);
问题是我的excel文件有12000条记录,但是它仅将2502条记录填充到我的数据表中.
The problem is my excel file has 12000 records however its only filling 2502 records into my data table.
数据适配器可以读取和写入数据表的记录数量是否有限制?
Is there a limit on how many records the data adapter can read and write to the data table?
推荐答案
问题可能是工作表包含混合数据,并且仅读取数字.解决方案是指定:
The problem might be that the sheet would contain mixed data and it was only reading numbers. The solution is to specify:
Properties="Excel 12.0;IMEX=1";
IMEX=1
允许阅读器导入所有数据,而不仅仅是数字.
IMEX=1
allows the reader to import all data not only numbers.
这篇关于OleDbDataAdapter未填充所有行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!