I'm trying to read .dbf file with datareader using OleDb like this:
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
The exception is of InvalidCastException type and says: Unable to case from System.__ComObject to IRowset.
When I tried to use OleDbAdapter to fill a table everything worked fine.
How do I read .dbf file using IDataReader?
my.dbfin your select command? Should that be the table name if it is not?