Главная страница
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.48 MB
Время: 0.009 c
14-58427
Tyrande
2003-08-01 20:38
2003.08.18
Проверка


14-58394
ACT
2003-08-04 13:06
2003.08.18
Ошибка в Application


14-58494
Man
2003-08-04 20:44
2003.08.18
как поменять цвет фона при стилей кисти bsHorizontal и т.п.


14-58455
Makhanev A.S.
2003-08-02 03:25
2003.08.18
Напомните название популярной песни


14-58496
dez
2003-08-04 20:15
2003.08.18
Как не дать мыше уйти с компонента