Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading DBF with VFPOLEDB driver

Tags:

dataset

oledb

dbf

I am using VFPOLEDB driver to read DBF files and I keep getting this error and I am not sure why and how to fix the problem:

The provider could not determine the Decimal value. For example, the row was just created, the default for the Decimal column was not available, and the consumer had not yet set a new Decimal value.

Here is the code. I call this routine to return a DataSet of the DBF file and display the data in a DataGridView.

public DataSet GetDBFData(FileInfo fi, string tbl)
{
    using (OleDbConnection conn = new OleDbConnection(
    @"Provider=VFPOLEDB.1;Data Source=" + fi.DirectoryName + ";"))
    {
        conn.Open();
        string command = "SELECT * FROM " + tbl;
        OleDbDataAdapter da = new OleDbDataAdapter(command, conn);
        DataSet ds = new DataSet();
        da.Fill(ds);
        return ds;
    }
}
like image 778
John Sheares Avatar asked Feb 17 '10 02:02

John Sheares


1 Answers

I found the solution here: Error reading certain numeric values with VFPOLEDB driver

SELECT CAST(FieldName As NUMERIC(11, 3)) From TableName
like image 60
John Prado Avatar answered Oct 20 '22 10:10

John Prado