auto increase 都是这样的, 删除后并不保证任何的连续, 它只能保证一个唯一 ID
想删除又要保证连续的可能性是没有的,可以的办法是建立另一个表用于保存空号的信息

解决方案 »

  1.   

    <<Delphi5开发人员指南>>中的方法是如何实现的呢?给个别的例子也行.只要能实现.写个源代码,那最好了
      

  2.   

    将这两个函数拷入你的程序中,调用方法:1.在Form中增加一个Table1控件。2.紧缩时调用
     PackTable(Table1);即可。Retorno是一个出错信息,你可以下管它。
    uses
      SysUtils, Classes, DB, DBTables, BDE, pubVar,
      Messages, Dialogs;procedure PackTable(var tblName : TTable);
    begin
      Retorno := '';
      with tblName do begin
         fDbiPackTable(tblName, True, Retorno)
      end;
    end;
    function fDbiPackTable(var TblName : TTable; bRegenIdxs: Boolean;
                           var Retorno : String): Boolean;
    var
     BdeResult : DbiResult;
     Props: CURProps;
     hDb: hDBIDb;
     TableDesc: CRTblDesc;
     bActive,bExclusive : Boolean;
    begin
     with TblName do begin
      bActive    := Active;
      bExclusive := Exclusive;
      if Active then Close;
      if not Exclusive then Exclusive := True;
      try
       Open;
      except
       Retorno := 'Cannot open the table in exclusive manner';
       Result := False;
       Exit;
      end;
     end; // Get the table properties to determine table type...
     Check(DbiGetCursorProps(TblName.Handle, Props)); if Props.szTableType = szDBase then begin
      BdeResult := DbiPackTable(TblName.DBHandle, TblName.Handle, nil,szDBase, bRegenIdxs);
      Case BdeResult of
       DBIERR_NONE           : Retorno := 'All table Indexes have been indexed';
       DBIERR_INVALIDHNDL    : Retorno := 'The Name of Table or the pointer to the same is Void';
       DBIERR_NOSUCHTABLE  : Retorno := 'The Table ' + TblName.TableName + ' not found';
       DBIERR_UNKNOWNTBLTYPE : Retorno := 'The type of table is unknown';
       DBIERR_NEEDEXCLACCESS : Retorno := 'The Table '  + TblName.TableName + 'it must be opened in exclusive manner';
      else
       Retorno := 'The BDE returns a not waited error';
      end;
      Result := (BdeResult = DBIERR_NONE);
     end else begin
      try
       if Props.szTableType = szPARADOX then begin
         FillChar(TableDesc, sizeof(TableDesc), 0);
         Check(DbiGetObjFromObj(hDBIObj(TblName.Handle), objDATABASE, hDBIObj(hDb)));
         StrPCopy(TableDesc.szTblName, TblName.TableName);
         StrPCopy(TableDesc.szTblType, Props.szTableType);
         TableDesc.bPack := True;
         TblName.Close;
         Check(DbiDoRestructure(hDb, 1, @TableDesc, nil, nil, nil, False));
         Result := True;
        end;
       except
        Retorno := 'An exception has taken place when packing the Paradox  Table';
        Result := False;
       end;
     end; with TblName do begin
      Close;
      Exclusive := bExclusive;
      Active    := bActive;
     end;
    end;
      

  3.   

    调试没通过,在Check(DbiGetObjFromObj(hDBIObj(TblName.Handle), objDATABASE, hDBIObj(hDb)));出捕捉到一个异常'An exception has taken place when packing the Paradox  Table'请继续指教
        
      

  4.   

    chenjiong(准程序员:升级中....):工具发给我好吗?
    我的信箱[email protected] 
    谢谢