我的代码:
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;
当我跑到oCmd.ExecuteReader()然后错误: 错误[HY000] [Microsoft] [ODBC dBase驱动程序]外部表格不是预期的格式。
答案 0 :(得分:1)
您刚刚显示了您的DBF文件所在的连接,但没有指定任何commandText
,请尝试类似
oCmd.CommandText = "SELECT * FROM TableName";