Click here to Skip to main content
14,666,459 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi,
When I am trying to import data from excel to table it's giving me following error :-
An exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll but was not handled in user code

Additional information: External table is not in the expected format.

I am using following code:-
Collapse
OleDbConnection excelConn = new OleDbConnection();
excelConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" + filelocation + "';Extended Properties=Excel 8.0");
 excelConn.Open();
Posted
Updated 12-Dec-10 17:40pm
v2
Comments
Toli Cuturicu 13-Dec-10 12:40pm
   
Descriptive titles, please. You got my 1.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Usually, this is because the file you're trying to read is not a real Excel workbook file. Are you trying to read a .CSV file with this?
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100