public DataTable GetVfpDataTable(string dbfFullPath) { string sqlString = "SELECT * FROM " + Path.GetFileName(dbfFullPath); OleDbConnection oleConn = new OleDbConnection("Provider=VFPOLEDB.1;Data Source=" + Path.GetDirectoryName(dbfFullPath) + ";Collating Sequence=MACHINE;"); OleDbCommand oleCmd = new OleDbCommand(sqlString, oleConn); OleDbDataReader oleReader; DataColumn col; DataRow row; DataTable dbfTable = new DataTable(); try { oleConn.Open(); //Bug in VFP OLE Data Adapter blows up with error "The provider could not determine the decimal value..." // must read with a data reader and fill the table row by row, column by column oleReader = oleCmd.ExecuteReader(); for (int i = 0; i < oleReader.FieldCount; i++) { col = new DataColumn(oleReader.GetName(i), oleReader.GetFieldType(i)); dbfTable.Columns.Add(col); } while (oleReader.Read()) { row = dbfTable.NewRow(); for (int i = 0; i < oleReader.FieldCount; i++) { try { row[i] = oleReader[i]; } catch (InvalidOperationException) { row[i] = DBNull.Value; //work-around for VFP OLEDB Provider glitch } } dbfTable.Rows.Add(row); } } catch (Exception eX) { throw new FileLoadException("Error Importing From VFP File\n" + eX.Message + "\nVFPDataAccess.cs:GetVfpDataTable()", dbfFullPath); } finally { oleConn.Close(); } return dbfTable; }