I'm trying to read a .dbf
file by following a tutorial I saw on Macoratti's website (obs guess everyone knows). And when you run the method just below, a OdbcException
is thrown with the following message: ERROR [IM001] [Microsoft][ODBC Driver Manager] O driver não oferece suporte para esta função
private DataTable lerDbf(string filename)
{
using (OdbcConnection conn = new OdbcConnection("Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=" +
System.IO.Path.GetFullPath(filename).Replace(System.IO.Path.GetFileName(filename), "") + ";Exclusive=No"))
{
string consulta = "SELECT * FROM [" + System.IO.Path.GetFileName(filename) + "]";
OdbcDataAdapter adapter = new OdbcDataAdapter(consulta, conn);
DataSet ds = new DataSet();
adapter.Fill(ds);
return ds.Tables[0];
}
}
Regarding the tutorial and the files, it says:
[...] just select the default FoxPro Dbase file and import ...
The .dbf
files I have to read on the system are generated from .xls
. Is this the problem? What happens? Is there something in the code, maybe in the connection string that is wrong?