Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Importing from excel

1 view
Skip to first unread message

Cdude

unread,
May 12, 2008, 7:51:45 AM5/12/08
to
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

Ignacio Machin ( .NET/ C# MVP )

unread,
May 12, 2008, 11:50:25 AM5/12/08
to

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

0 new messages