Importing from excel

  • Thread starter Thread starter Cdude
  • Start date Start date
C

Cdude

OleDbConnection excel1 = new OleDbConnection();

excel1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Documents and Settings\\Jed\\My Documents\\pro cd\
\testsheet.xls;Extended Properties=Excel 8.0;";
OleDbDataAdapter fillds = new OleDbDataAdapter("SELECT
Barcode,Part_Count,Cycle_Time FROM [Sheet1$]", excel1);

System.Data.DataTable ds = new
System.Data.DataTable();
fillds.Fill(ds);

This is the code i am using but i am getting this error when i execute
the fill statement.

External table is not in the expected format.

What am i doing wrong here?Please help. thanks in advance
 
The error is meaningful .. there is some issue with the data in the Sheet.
Check that the data type is unique for every column.

HTH
 
 OleDbConnection excel1 = new OleDbConnection();

excel1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Documents and Settings\\Jed\\My Documents\\pro cd\
\testsheet.xls;Extended Properties=Excel 8.0;";
                OleDbDataAdapter fillds = new OleDbDataAdapter("SELECT
Barcode,Part_Count,Cycle_Time FROM [Sheet1$]", excel1);

                System.Data.DataTable ds = new
System.Data.DataTable();
                fillds.Fill(ds);

This is the code i am using but i am getting this error when i execute
the fill statement.

External table is not in the expected format.

What am i doing wrong here?Please help. thanks in advance

Hi,


I have posted in the past code to read from excel in the way you want,
do a search in the archives by "ignacio machin" excel code and you
should find it
 
Back
Top