not all data insert in convert from excell to database
i have this code:
ConnectString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + ExcelFile + ";Extended Properties=\"Excel 12.0 Xml;HDR=No\"";
SheetName = SheetName.Substring(0, SheetName.Length - 5);
OleDbConnection Connection = new OleDbConnection();
Connection.ConnectionString = ConnectString;
try {Connection.Open();}
catch (Exception EX)
{
MessageBox.Show(EX.Message);
}
OleDbDataAdapter Command = new OleDbDataAdapter("SELECT * FROM [" + SheetName + "$]", Connection);
DataSet ExcelData = new DataSet();
try {Command.Fill(ExcelData);}
catch (Exception EX)
{
MessageBox.Show(EX.Message);
}
finally
{
if (Connectio开发者_Go百科n.State != ConnectionState.Closed)
Connection.Close();
}
but not all the data in column 1 insert - i get empty data why ? what can be wrong ?
thank's in advance
When importing from Excel, datatypes for the columns are by default guessed based on the contents of the first eight rows. If the values are blank in the first 8 rows for a given column, that can result in no data for the column at all. This can be overridden in the registry. I would suggest investigating that possibility. Here's a good writeup.
http://blog.lab49.com/archives/196
精彩评论