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

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


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

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天全站免登陆