ado.net读取dbf文件内容到DataTable

来源:互联网 发布:win7系统服务优化工具 编辑:程序博客网 时间:2024/05/12 19:17



            OdbcConnection conn = new OdbcConnection();
            string table = @"D:\05164108.DBF";
            string connStr = @"Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=" + table + ";Exclusive=No;NULL=NO;Collate=Machine;BACKGROUNDFETCH=NO;DELETED=NO";
            conn.ConnectionString = connStr;
            conn.Open();

            string sql = @"select * from " + table + " Where !Deleted() ";//where !Deleted() 这句不加查出来的数据与文件中条数不匹配
            OdbcDataAdapter da = new OdbcDataAdapter(sql, conn);
            DataTable dt = new DataTable();
            da.Fill(dt);           

0 0
原创粉丝点击