BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to pack table Foxpro

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop)
View previous topic :: View next topic  
Author Message
Bpk. Adi Wira Kusuma
Guest





PostPosted: Sat Mar 05, 2005 11:09 am    Post subject: How to pack table Foxpro Reply with quote



I use the D6 and Foxpro as its database. How to for the Pack of table by
Delphi's code? And how to avoid the data loss at the time of extinct
electrics (Power is off).

When should I make Index? Whether the moment of making just report, or each
time I open table?

Please, I need your help


[email]adi_wira_kusuma (AT) yahoo (DOT) com.sg[/email]



Back to top
Lauro Lima
Guest





PostPosted: Sat Mar 05, 2005 11:31 am    Post subject: Re: How to pack table Foxpro Reply with quote



Hi,, You can use My function....
Some message are in portuguess/Brazil,,, I didn't have time to translate
it........
maybe can help.... This procedure work for DBASE and Paradox as you can see
under....

Procedure DBPack( oTable:TTable );
Var
iResult: DBIResult;
szErrMsg: DBIMSG;
// pTblDesc: pCRTblDesc;
bExclusive: Boolean;
bActive : Boolean;
Begin
{ Salva o estado Atual da Tabela}
With oTable Do
Begin
bExclusive := Exclusive;
bActive := Active;
DisableControls;
close;
Exclusive := True;
End;
{ Pra tabelas Dbase, uma DBiPackTable ; Para Tabelas
Paradox,DbiDoRestructure}
Case oTable.TableType of
ttdBase,ttFoxPro:
Begin
oTable.Open;
//executa o pack
iResult := DbiPackTable( oTable.DBHandle,oTable.Handle,nil,nil,True);
// se nao teve erros
If iResult <> DBIERR_NONE Then
Begin
DbiGetErrorString( iResult,szErrMsg);
MessageDlg( szErrMsg,mtError,[mbOk],0);
End;
End;
{
ttParadox:
Begin
If MaxAvail < SizeOf( CRTblDesc ) Then
MessageDlg('Não há memória suficiente para compactar a tabela',
mtError,[mbOk],0)
Else
Begin
GetMem( pTblDesc, SizeOf( CRTblDesc));
FillChar( pTblDesc^,SizeOf( CRTblDesc),0);
With pTblDesc^ Do
Begin
StrPcopy( szTblName, oTable.TableName);
StrPCopy( szTblType,szParadox);
bPack := True;
End;
iResult := DbiDoRestructure( oTable.DBHandle,1,
pTblDesc,nil,nil,nil,False);
If iResult <> DBIERR_NONE Then
Begin
DbiGetErrorString( iResult, szErrmsg )
MessageDlg( szErrMsg,mtError,[mbOk],0);
End;
FreeMem( pTblDesc,SizeOf( CRTblDesc));
End;
End;
}
Else
MessageDlg('Esse Tipo de tabela não pode ser compactada!',
mtError,[mbOk],0);
End;
{ Restaura o estado da tabela anterior}
With oTable Do
Begin
Close;
Exclusive := bExclusive;
Active := bActive;
EnableControls;
End;
End;

"Bpk. Adi Wira Kusuma" <adi_wira_kusuma (AT) yahoo (DOT) com.sg> escreveu na mensagem
news:4229931d (AT) newsgroups (DOT) borland.com...
Quote:
I use the D6 and Foxpro as its database. How to for the Pack of table by
Delphi's code? And how to avoid the data loss at the time of extinct
electrics (Power is off).

When should I make Index? Whether the moment of making just report, or
each
time I open table?

Please, I need your help


[email]adi_wira_kusuma (AT) yahoo (DOT) com.sg[/email]






Back to top
Bpk. Adi Wira Kusuma
Guest





PostPosted: Sat Mar 05, 2005 3:03 pm    Post subject: Re: How to pack table Foxpro Reply with quote



Thanks

"Lauro Lima" <Lauro123 (AT) yahoo (DOT) com> wrote

Quote:
Hi,, You can use My function....
Some message are in portuguess/Brazil,,, I didn't have time to translate
it........
maybe can help.... This procedure work for DBASE and Paradox as you can
see
under....

Procedure DBPack( oTable:TTable );
Var
iResult: DBIResult;
szErrMsg: DBIMSG;
// pTblDesc: pCRTblDesc;
bExclusive: Boolean;
bActive : Boolean;
Begin
{ Salva o estado Atual da Tabela}
With oTable Do
Begin
bExclusive := Exclusive;
bActive := Active;
DisableControls;
close;
Exclusive := True;
End;
{ Pra tabelas Dbase, uma DBiPackTable ; Para Tabelas
Paradox,DbiDoRestructure}
Case oTable.TableType of
ttdBase,ttFoxPro:
Begin
oTable.Open;
//executa o pack
iResult := DbiPackTable(
oTable.DBHandle,oTable.Handle,nil,nil,True);
// se nao teve erros
If iResult <> DBIERR_NONE Then
Begin
DbiGetErrorString( iResult,szErrMsg);
MessageDlg( szErrMsg,mtError,[mbOk],0);
End;
End;
{
ttParadox:
Begin
If MaxAvail < SizeOf( CRTblDesc ) Then
MessageDlg('Não há memória suficiente para compactar a tabela',
mtError,[mbOk],0)
Else
Begin
GetMem( pTblDesc, SizeOf( CRTblDesc));
FillChar( pTblDesc^,SizeOf( CRTblDesc),0);
With pTblDesc^ Do
Begin
StrPcopy( szTblName, oTable.TableName);
StrPCopy( szTblType,szParadox);
bPack := True;
End;
iResult := DbiDoRestructure( oTable.DBHandle,1,
pTblDesc,nil,nil,nil,False);
If iResult <> DBIERR_NONE Then
Begin
DbiGetErrorString( iResult, szErrmsg )
MessageDlg( szErrMsg,mtError,[mbOk],0);
End;
FreeMem( pTblDesc,SizeOf( CRTblDesc));
End;
End;
}
Else
MessageDlg('Esse Tipo de tabela não pode ser compactada!',
mtError,[mbOk],0);
End;
{ Restaura o estado da tabela anterior}
With oTable Do
Begin
Close;
Exclusive := bExclusive;
Active := bActive;
EnableControls;
End;
End;

"Bpk. Adi Wira Kusuma" <adi_wira_kusuma (AT) yahoo (DOT) com.sg> escreveu na mensagem
news:4229931d (AT) newsgroups (DOT) borland.com...
I use the D6 and Foxpro as its database. How to for the Pack of table by
Delphi's code? And how to avoid the data loss at the time of extinct
electrics (Power is off).

When should I make Index? Whether the moment of making just report, or
each
time I open table?

Please, I need your help


[email]adi_wira_kusuma (AT) yahoo (DOT) com.sg[/email]








Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Desktop) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.