使用 VFPOLEDB 驱动程序读取 DBF [英] Reading DBF with VFPOLEDB driver

查看:45
本文介绍了使用 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 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.

这篇关于使用 VFPOLEDB 驱动程序读取 DBF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆