ERROR External table is not in the expected format when I get data from file dbf in C#

1.4k views Asked by At

My code:

OdbcConnection conn = new OdbcConnection();
conn.ConnectionString ="Driver={Microsoft dBASE Driver (*.dbf)};Driverid=277;Dbq=D:\\DBF\\";
conn.Open();
OdbcCommand oCmd = conn.CreateCommand();
DataTable dt = new DataTable();
dt.Load(oCmd.ExecuteReader());
conn.Close();
dataGridView1.DataSource = dt;

When I run to oCmd.ExecuteReader() then error: ERROR [HY000] [Microsoft][ODBC dBase Driver] External table is not in the expected format.

1

There are 1 answers

0
gunvant.k On

You just showed your connection where your DBF file is, but didn't specified any commandText, Try something like that

oCmd.CommandText = "SELECT * FROM TableName";