query_csjl.SQL.Clear;
query_csjl.SQL.Add('Delete From blda Where Bh=:Code');
query_csjl.ParamByName('Code').AsInteger := table_blda.fieldbyname('bh').AsInteger;
query_csjl.ExecSQL;
query_csjl.SQL.Clear;
query_csjl.SQL.Add('Pack blda');
query_csjl.ExecSQL;SQL语句好像只能在上面做个删除记号,最后是不是要用Pack语句,如果是的话应该怎么样用呢?多谢了。。

解决方案 »

  1.   

    最后追加query_csjlpost;
    或者query_csjlupdatebatch;
      

  2.   

    不好意思 我说的是SQL Sever数据库 你试试吧?
      

  3.   

    当然,Table必须用exclusive方式打开!
    对于Paradox数据库,就麻烦一些了:
    // Pack a Paradox or dBASE table
    // The table must be opened execlusively before calling this function...
    procedure PackTable(Table: TTable);
    var
      Props: CURProps;
      hDb: hDBIDb;
      TableDesc: CRTblDesc;begin
      // Make sure the table is open exclusively so we can get the db handle...
      if Table.Active = False then
        raise EDatabaseError.Create('Table must be opened to pack');
      if Table.Exclusive = False then
        raise EDatabaseError.Create('Table must be opened exclusively to pack');  // Get the table properties to determine table type...
      Check(DbiGetCursorProps(Table.Handle, Props));  // If the table is a Paradox table, you must call DbiDoRestructure...
      if Props.szTableType = szPARADOX then
      begin
        // Blank out the structure...
        FillChar(TableDesc, sizeof(TableDesc), 0);
        //  Get the database handle from the table's cursor handle...
        Check(DbiGetObjFromObj(hDBIObj(Table.Handle), objDATABASE, hDBIObj(hDb)));
        // Put the table name in the table descriptor...
        StrPCopy(TableDesc.szTblName, Table.TableName);
        // Put the table type in the table descriptor...
        StrPCopy(TableDesc.szTblType, Props.szTableType);
        // Set the Pack option in the table descriptor to TRUE...
        TableDesc.bPack := True;
        // Close the table so the restructure can complete...
        Table.Close;
        // Call DbiDoRestructure...
        Check(DbiDoRestructure(hDb, 1, @TableDesc, nil, nil, nil, FALSE));
      end
      else
        // If the table is a dBASE table, simply call DbiPackTable...
        if Props.szTableType = szDBASE then
          Check(DbiPackTable(Table.DBHandle, Table.Handle, nil, szDBASE, TRUE))
        else
          // Pack only works on PAradox or dBASE; nothing else...
          raise EDatabaseError.Create('Table must be either of Paradox or dBASE ' +
                   'type to pack');  Table.Open;
    end;
      

  4.   

    SQL Sever我都知道,关键是Paradox。偶对Delphi不熟,请各位大虾帮忙啊。
      

  5.   

    1、如果是SQL,Oracle等大型数据库,不需要pack
    2、Access数据库也不需要pack
    3、如果是db,dbf数据表,就需要了。有两种方式,一种通过打断文件头和文件体的物理连接,来实现。二种通过文件删除的方法,然后重新创建,这样是最简单快捷的方法。