Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2003.08.18;
Скачать: CL | DM;

Вниз

Упаковка dbf таблицы   Найти похожие ветки 

 
Алексей   (2003-07-23 08:29) [0]

Зравствуйте!
По совету присутствующих тут людей начал разбираться в базах.
Но т.к. пока книг возможности купить не было (живу в поселке),
изучаю "методом тыка", так что не ругайте за глупый вопрос.
Я хотел упаковать dbf - таблицу функцией PackTable из RxLib,
но получил ошибку: "Table Is Busy".
Что нужно подправить?
И еще, может кто подскажет адреса, где есть хорошие доки по базам
для изучающих с нуля, а то у нас Internet очень тормозит и искать
очень долго и дорого.
Заранее спасибо.


 
Тупой ©   (2003-07-23 08:33) [1]

Свойство Active в таблице должно быть FALSE;


 
Tornado ©   (2003-07-23 09:03) [2]

http://blackman.wp-club.net/
http://www.delphihelp.boom.ru/doc.html
http://delphi.bugs.ru/
http://delphi.mastak.ru/cgi-bin/links.pl?get=39
http://www.sources.ru/delphi_src1.shtml


 
Nikola   (2003-07-23 09:32) [3]

А ты не хочешь стандартными средствами? Типа
Tblzak - это TTable
Tblzak.Open;
if not Tblzak.Active then
raise EDatabaseError.Create("Table must be opened to pack");
if not Tblzak.Exclusive then
raise EDatabaseError.Create("Table must be opened exclusively to pack");
Check(DbiPackTable(Tblzak.DBHandle, Tblzak.Handle, nil, szDBASE, False));
Tblzak.Close;
Tblallzak.Open;
if not Tblallzak.Active then
raise EDatabaseError.Create("Table must be opened to pack");
if not Tblzak.Exclusive then
( "Table must be opened exclusively to pack") А ты не хочешь стандартными средствами? Типа
Tblzak - это TTable
Tblzak.Open;
if not Tblzak.Active then
raise EDatabaseError.Create("Table must be opened to pack");
if not Tblzak.Exclusive then
raise EDatabaseError.Create("Table must be opened exclusively to pack");
Check(DbiPackTable(Tblzak.DBHandle, Tblzak.Handle, nil, szDBASE, False));
Tblzak.Close;
Tblallzak.Open;
if not Tblallzak.Active then
raise EDatabaseError.Create("Table must be opened to pack");
if not Tblzak.Exclusive then
raise EDatabaseError.Create("Table must be opened exclusively to pack");
Check(DbiPackTable(Tblallzak.DBHandle, Tblallzak.Handle, nil, szDBASE, False));
Tblallzak.Close;

Только пропиши в uses BDE - В help это есть


 
RRR   (2003-07-23 14:44) [4]

Взято из Helpa
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 not Table.Active then
raise EDatabaseError.Create("Table must be opened to pack");
if not Table.Exclusive 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...
( "Table must be either of Paradox or dBASE " +

"type to pack"
) Взято из Helpa
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 not Table.Active then
raise EDatabaseError.Create("Table must be opened to pack");
if not Table.Exclusive 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;


 
Rulja ©   (2003-07-24 08:35) [5]

Извините, что влезаю, сам наступал на такие грабли. Если пересмотреть весь код из helpa то пакуют всего две строки:
одна базу Paradox
Check(DbiGetObjFromObj(hDBIObj(Table.Handle), objDATABASE, hDBIObj(hDb)));
вторая базу dBASE
Check(DbiPackTable(Table.DBHandle, Table.Handle, nil, szDBASE, True))
Только весь прикол в том, что самое вкусное здесь не показано, в USES в самом начале надо присоединить (прописать) блок BDE, как тебе ранее советовали. И далее если ты знаешь тип своей базы весь остальной код по проверке ее типа тебе не нужен. Кстати еще перед упаковкой базы (по моему, точно не помню, попробуешь)Table.Exclusive включить, т.е. получить монопольный доступ к пакуемой базе.



Страницы: 1 вся ветка

Текущий архив: 2003.08.18;
Скачать: CL | DM;

Наверх




Память: 0.49 MB
Время: 0.016 c
14-58386
Юля
2003-08-04 14:58
2003.08.18
Richedit


14-58439
syte_ser78
2003-07-31 15:47
2003.08.18
Удаление записи из ДБ


14-58413
sergiu
2003-06-04 17:55
2003.08.18
color button??


14-58417
Asteroid
2003-08-03 04:14
2003.08.18
Real Audio Player


14-58443
brainstorm
2003-08-02 17:39
2003.08.18
Как зделать так что бы моя программа не светилась по ALT+CTRL+DEL