Hồ Tấn Phong
Hồ Tấn Phong

Reputation: 23

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

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.

Upvotes: 0

Views: 1463

Answers (1)

gunvant.k
gunvant.k

Reputation: 1086

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";

Upvotes: 1

Related Questions