使用 VFPOLEDB 驱动程序读取 DBF驱动程序、VFPOLEDB、DBF

由网友(北方女王)分享简介:我正在使用 VFPOLEDB 驱动程序读取 DBF 文件,但一直收到此错误,我不知道为什么以及如何解决此问题:I am using VFPOLEDB driver to read DBF files and I keep getting this error and I am not sure why and how...

我正在使用 VFPOLEDB 驱动程序读取 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:

提供程序无法确定十进制值.例如,行刚刚创建,Decimal 列的默认值不可用,消费者尚未设置新的 Decimal 值.

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.

这里是代码.我调用此例程返回 DBF 文件的 DataSet 并在 DataGridView 中显示数据.

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;
    }
}

推荐答案

我终于解决了这个问题,方法是获取表模式,然后在 select 语句中将所有非字符字段转换为 varchar.足以预览表格的内容.

I finally solved the problem by getting the table schema and then casting all of non-character fields to varchar in the select statement. Good enough for previewing the contents of the table.

阅读全文

相关推荐

最新文章