1
OleDbConnection c= new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\\Folder; Extended Properties=dBASE IV;");
c.open();
OleDbDataAdapter da=new OleDbDataAdapter("Select * from Table11",c);
DataSet ds=new Dataset();
da.Fill(ds);
c.Close();

I was trying to read .dbf table from c# and I have write above code for it, but I am getting this error:

External Table is not in Expected Format

p.s.w.g
  • 146,324
  • 30
  • 291
  • 331
hemant037
  • 11
  • 2
  • The problem is with your connection see [this discussion](http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/f461a6c6-3c03-46e0-8c9b-bb04a77ed2ce) – Habib May 08 '13 at 06:23

2 Answers2

1

Try like this;

public static string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\\Folder; Extended Properties=dBASE IV;";
OleDbConnection c= new OleDbConnection(connStr);
c.open();
OleDbDataAdapter da=new OleDbDataAdapter("Select * from Table11",c);
DataSet ds=new Dataset();
da.Fill(ds);
c.Close();

From Excel "External table is not in the expected format."

"External table is not in the expected format." typically occurs when trying to use an Excel 2007 file with a connection string that uses: Microsoft.Jet.OLEDB.4.0 and Extended Properties=Excel 8.0

Community
  • 1
  • 1
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
  • Thanks @Sonar GOnul for your reply.. But its also not working.. giving same error.. – hemant037 May 08 '13 at 06:38
  • @hemant037 Are you sure you made `static` both your `conn` and excel file path? Check out http://stackoverflow.com/a/1363480/447156 – Soner Gönül May 08 '13 at 06:40
  • @hemant037 I think you should write `Data Source` part of your connection string full path of your excel file like `@"E:\\Folder\example.xlsx"` – Soner Gönül May 08 '13 at 06:46
  • @Sonar Gonul : Sir i am not trying to connect with xlsx file but i want to connnect with .dbf file..and i had tried by adding data source with full file name Like.. -> @"E:\folder\table11.dbf.... but it still not working.. Thanks – hemant037 May 08 '13 at 06:54
0
static string connStr ="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\Folder\sample.xlsx; Extended Properties=dBASE IV;";
Ailis
  • 167
  • 4