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




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

你可能感兴趣的:(VS)