dbf的文件格式很简单,自己访问了。给你一转贴一篇dbf文件格式的文章,不过是英文的,但是读起来不是很费力。但是好像对delphi建立的文件格式不是很一样。
dbase flie format----------------------------------------------------------------------------
genaral format of .dbf files in xbase languages 18-nov-96
----------------------------------------------------------------------------
applies for / supported by:fs = flagship d3 = dbaseiii+
fb = foxbase d4 = dbaseiv
fp = foxpro d5 = dbasev
cl = clipper
1. dbf structure
================byte description
------+--------------------------------------
0..n .dbf header (see 2 for size, byte 8)
n+1 1st record of fixed length (see 2&3) 2nd record (see 2 for size, byte 10) \ if dbf is
... / not empty
last record /
last optional: 0x1a (eof byte)
2. dbf header (variable size, depending on field count)
=======================================================byte size contents description applies for (supported by)
----+----+--------+----------------------------+-----------------------------
00 1 0x03 plain .dbf fs, d3, d4, d5, fb, fp, cl
0x04 plain .dbf d4, d5 (fs)
0x05 plain .dbf d5, fp (fs)
0x43 with .dbv memo var size fs
0xb3 with .dbv and .dbt memo fs
0x83 with .dbt memo fs, d3, d4, d5, fb, fp, cl
0x8b with .dbt memo in d4 format d4, d5
0x8e with sql table d4, d5
0xf5 with .fmp memo fp
01 3 yymmdd last update digits all
04 4 ulong number of records in file all
08 2 ushort header size in bytes all
10 2 ushort record size in bytes all
12 2 0,0 reserved all
14 1 0x01 begin transaction d4, d5
0x00 end transaction d4, d5
0x00 ignored fs, d3, fb, fp, cl
15 1 0x01 encryptpted d4, d5
0x00 normal visible all
16 12 0 (1) multi-user environment use d4,d5
28 1 0x01 production index exists fp, d4, d5
0x00 index upon demand all
29 1 n language driver id d4, d5
0x01 codepage 437 dos usa fp
0x02 codepage 850 dos multi ling fp
0x03 codepage 1251 windows ansi fp
0xc8 codepage 1250 windows ee fp
0x00 ignored fs, d3, fb, fp, cl
30 2 0,0 reserved all
32 n*32 field descriptor, see (2a) all
+1 1 0x0d header record terminator all
2a. field descriptor array in dbf header (fix 32 bytes for each field)
========================================byte size contents description applies for (supported by)
----+----+--------+----------------------------+-----------------------------
0 11 asci field name, 0x00 termin. all
11 1 asci field type (see 2b) all
12 4 n,n,n,n fld address in memory d3
n,n,0,0 offset from record begin fp
0,0,0,0 ignored fs, d4, d5, fb, cl
16 1 byte field length, bin (see 2b) all \ fs,cl: for c field type,
17 1 byte decimal count, bin all / both used for fld lng
18 2 0,0 reserved all
20 1 byte work area id d4, d5
0x00 unused fs, d3, fb, fp, cl
21 2 n,n multi-user dbase d3, d4, d5
0,0 ignored fs, fb, fp, cl
23 1 0x01 set fields d3, d4, d5
0x00 ignored fs, fb, fp, cl
24 7 0..0 reserved all
31 1 0x01 field is in .mdx index d4, d5
0x00 ignored fs, d3, fb, fp, cl
2b. field type and size in dbf header, field descriptor (1 byte)
=======================================================size type description/storage applies for (supported by)
------+---------+------------------------------+-----------------------------
c 1..n char ascii (oem code page chars) all
rest= space, not \0 term.
n = 1..64kb (using deci count) fs
n = 1..32kb (using deci count) fp, cl
n = 1..254 all
d 8 date 8 ascii digits (0..9) in the all
yyyymmdd format
f 1..n numeric ascii digits (-.0123456789) fs, d4, d5, fp
variable pos. of float.point
n = 1..20
n 1..n numeric ascii digits (-.0123456789) all
fix posit/no float.point
n = 1..20 fs, fp, cl
n = 1..18 d3, d4, d5, fb
l 1 logical ascii chars (yynnttff space) fs, d3, fb, fp, cl
ascii chars (yynnttff ?) d4, d5 (fs)
m 10 memo 10 digits repres. the start all
block posit. in .dbt file, or
10spaces if no entry in memo
v 10 variable variable, bin/asc data in .dbv fs
4bytes bin= start pos in memo
4bytes bin= block size
1byte = subtype
1byte = reserved (0x1a)
10spaces if no entry in .dbv
p 10 picture binary data in .ftp fp
structure like m
b 10 binary binary data in .dbt d5
structure like m
g 10 general ole objects d5, fp
structure like m
2 2 short int binary int max +/- 32767 fs
4 4 long int binary int max +/- 2147483647 fs
8 8 double binary signed double ieee fs
3. each dbf record (fix length)
==================byte size description applies for (supported by)
------+----+--------------------------------------+--------------------------
0 1 deleted flag "*" or not deleted " " all
1..n 1.. x-times contents of fields, fixed all
length, unterminated.
for n, see (2) byte 10..11---
multisoft datentechnik gmbh 返回

解决方案 »

  1.   

    简单的介绍一下,08~09两个字节是说文件头的大小,去掉文件头就是数据了,dbf文件数据都是定长的。10~~11两个字节是每条纪录的大小。记录的第一个字符是20h那就是合法纪录,如果是2ah那就是已经删除纪录。文件以1ah为结尾。
      

  2.   

    那么人工的把是2a的改写成20,把20得改写为2a,在调用sql。如果怕影响数据稳定,可以通过一个临时表。
      

  3.   

    我忘了是Table还是CacheUpdate有一个属性
    它能设置显示的记录为 普通的,更新的,删除的,空的等.
      

  4.   

    请看Borland公司的解决方案:
    community.borland.comArticle #16195: Showing deleted records in a dBASE table. Technical Information DatabaseTI1195D.txt   Showing deleted records in a dBASE table.
    Category   :Database Programming
    Platform    :All
    Product    :Delphi  AllDescription:
    Q:   How can I view dBASE records ed for deletion. That is, 
    I want to view those records ed as "soft deletion"?  A:  In a dBASE table, records are not removed from the table 
    until the table is packed.  Until that happens, records that 
    are "deleted" are actually just ed as "to be" deleted. To 
    show these existing but not displayed records, the following 
    function, ShowDeleted(), makes use of a BDE API function, 
    DbiSetProp(), to show records ed for deletion.  It is not 
    necessary to close and re-open the table when using this 
    function.  ShowDeleted() takes a TTable and a boolean variable 
    as parameters. The boolean parameter determines whether or not 
    to show deleted records. Example code follows:
    -----unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls,
      Forms, Dialogs, StdCtrls, ExtCtrls, DBCtrls, Grids, DBGrids,
      DB, DBTables;type
      TForm1 = class(TForm)
        Table1: TTable;
        DataSource1: TDataSource;
        DBGrid1: TDBGrid;
        DBNavigator1: TDBNavigator;
        CheckBox1: TCheckBox;
        procedure CheckBox1Click(Sender: TObject);
      public
        procedure ShowDeleted(Table: TTable; ShowDeleted: Boolean);
      end;var
      Form1: TForm1;implementationuses DBITYPES, DBIERRS, DBIPROCS;{$R *.DFM}procedure TForm1.ShowDeleted(Table: TTable; ShowDeleted: Boolean);
    var
      rslt: DBIResult;
      szErrMsg: DBIMSG;
    begin
      Table.DisableControls;
      try
        Check(DbiSetProp(hDBIObj(Table.Handle), curSOFTDELETEON,
          LongInt(ShowDeleted)));
      finally
        Table.EnableControls;
      end;
      Table.Refresh;
    end;procedure TForm1.CheckBox1Click(Sender: TObject);
    begin
      ShowDeleted(Table1, CheckBox1.Checked);
    end;end.
    Reference:
    7/16/98 4:34:05 PM
     
    Last Modified: 01-SEP-99