我试图读取使用的DataReader OleDb的.dbf文件这样的读取DBF文件:使用的IDataReader在C#中
const string OleDbConnectionString =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydbase;Extended Properties=dBASE IV;";
var connection = new OleDbConnection(OleDbConnectionString);
connection.Open();
var command = new OleDbCommand("select * from my.dbf", connection);
reader = command.ExecuteReader();
Console.WriteLine(reader.Read()); // true
Console.WriteLine(reader[0].ToString()); // exception
唯一的例外是InvalidCastException
型的,并说:无法情况下,从System.__ComObject
到IRowset
。 当我试图用OleDbAdapter
来填充表格时,一切正常。
如何使用IDataReader读取.dbf文件?
什么是你的选择命令中的'my.dbf'?如果不是,那该不该是表名呢? – dpp