not all data insert in convert from excell to database
Posted
by Gold
on Stack Overflow
See other posts from Stack Overflow
or by Gold
Published on 2009-12-21T15:27:09Z
Indexed on
2010/04/25
5:33 UTC
Read the original article
Hit count: 167
c#
|excel-2007
hi
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 (Connection.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
© Stack Overflow or respective owner