简体   繁体   中英

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.

您仅显示了DBF文件所在的连接,但未指定任何commandText ,请尝试类似的操作

oCmd.CommandText = "SELECT * FROM TableName";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM