powered by simpleCommunicator - 2.0.60     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Delphi [игнор отключен] [закрыт для гостей] / как упаковать таблицу DBF?
3 сообщений из 3, страница 1 из 1
как упаковать таблицу DBF?
    #32213179
RDen
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Подскажите плз. Удаляю записи из таблицы DBF методом Delete, после этого таблицу надо упаковать. Как?
...
Рейтинг: 0 / 0
как упаковать таблицу DBF?
    #32213215
Фотография Andrew Campball
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Через DBE

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
procedure PackTable(TblName: string);
var
  tbl: TTable;
  cProps: CURProps;
  hDb: hDBIDb;
  TblDesc: CRTblDesc;
begin

  tbl := TTable.Create(nil);
  with tbl do
  begin
    Active := False;
    DatabaseName := ExtractFilePath(TblName);
    TableName := ExtractFileName(TblName);
    Exclusive := True;
    Open;
  end;

  // Added  23 / 7 / 2000  to make sure that the current path is the same as the table
  //see note below

  SetCurrentDir(ExtractFilePath(TblName));

  // Make sure the table is open exclusively so we can get the db handle...
  if not tbl.Active then
    raise EDatabaseError.Create('Table must be opened to pack');

  if not tbl.Exclusive then
    raise EDatabaseError.Create('Table must be opened exclusively to pack');

  // Get the table properties to determine table type...
  Check(DbiGetCursorProps(tbl.Handle, cProps));

  // If the table is a Paradox table, you must call DbiDoRestructure...
  if (cProps.szTableType = szPARADOX) then
  begin
    // Blank out the structure...
    FillChar(TblDesc, sizeof(TblDesc),  0 );
    // Get the database handle from the table's cursor handle...
    Check(DbiGetObjFromObj(hDBIObj(tbl.Handle), objDATABASE, hDBIObj(hDb)));
    // Put the table name in the table descriptor...
    StrPCopy(TblDesc.szTblName, tbl.TableName);
    // Put the table type in the table descriptor...
    StrPCopy(TblDesc.szTblType, cProps.szTableType);
    // Set the Pack option in the table descriptor to TRUE...
    TblDesc.bPack := True;
    // Close the table so the restructure can complete...
    tbl.Close;
    // Call DbiDoRestructure...
    Check(DbiDoRestructure(hDb, 1, @TblDesc, nil, nil, nil, False));
  end
  else
    {// If the table is a dBASE table, simply call DbiPackTable...} if
      (cProps.szTableType = szDBASE) then
      Check(DbiPackTable(tbl.DBHandle, tbl.Handle, nil, szDBASE, True))
    else
      // Pack only works on Paradox or dBASE; nothing else...
      raise EDatabaseError.Create('You can only pack Paradox or dBase tables!');

  with tbl do
  begin
    if Active then
      Close;
    Free;
  end;
end;


Если работаеш через TDBF, то нам есть свой метод PAckTable
...
Рейтинг: 0 / 0
как упаковать таблицу DBF?
    #32214096
RDen
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
to Andrew Campball - спасибо, всё получилось. Упрощенно выглядит так:
Table.Active:=False;
Table.Exclusive:=True;
Table.Open;
Check(DbiPackTable(Table.DBHandle, Table.Handle, nil, szDBASE, True));
...
Рейтинг: 0 / 0
3 сообщений из 3, страница 1 из 1
Форумы / Delphi [игнор отключен] [закрыт для гостей] / как упаковать таблицу DBF?
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]