verificando se o arquivo está em uso
Caros colegas estou tentando verificar se um arquivo esta em uso por outra estaçao. Acontece que depois da mensagem informando que o arquivo está em uso estou tentando fechar o formulario mas não está dando certo, ou seja ele continua a sequencia do codigo. Onde está o erro:
procedure TF_VendaPrazo.FormShow(Sender: TObject);
begin
deu_erro:=false;
try
tb_ficha.tablename:=marq;
tb_ficha.TableType := ttfoxpro;
tb_ficha.Exclusive:=true;
tb_ficha.Open;
tb_ficha.Active:=true;
except
on EDataBaseError do
Begin
deu_erro:=true;
MessageDlg(´Ficha de cliente já está em uso em outro terminal!´,mtError, [mbOk],0);
tb_ficha.active:=false;
tb_ficha.close;
exit;
End;
end;
if deu_erro=true then
begin
f_vendaprazo.close;
f_clientes.edt_nome.setfocus;
end;
procedure TF_VendaPrazo.FormShow(Sender: TObject);
begin
deu_erro:=false;
try
tb_ficha.tablename:=marq;
tb_ficha.TableType := ttfoxpro;
tb_ficha.Exclusive:=true;
tb_ficha.Open;
tb_ficha.Active:=true;
except
on EDataBaseError do
Begin
deu_erro:=true;
MessageDlg(´Ficha de cliente já está em uso em outro terminal!´,mtError, [mbOk],0);
tb_ficha.active:=false;
tb_ficha.close;
exit;
End;
end;
if deu_erro=true then
begin
f_vendaprazo.close;
f_clientes.edt_nome.setfocus;
end;
Ghsol
Curtidas 0
Respostas
Siam
23/10/2006
Tente retirar o [b:99e59508fc]exit[/b:99e59508fc] abaixo do [b:99e59508fc]except[/b:99e59508fc].
GOSTEI 0
Ghsol
23/10/2006
carol colega fiz como vc indicou mas mesmo assim ele não executa a sequencia de codigo após o erro conforme abaixo:
if deu_erro=true then
begin
f_vendaprazo.close;
f_clientes.edt_nome.setfocus;
exit;
end;
if deu_erro=true then
begin
f_vendaprazo.close;
f_clientes.edt_nome.setfocus;
exit;
end;
GOSTEI 0
Ghsol
23/10/2006
caros colegas, outro detalhe se retirar o exit deste bloco de código também aparece a mensagem informando ´table is busy´
GOSTEI 0
Siam
23/10/2006
Pode ser que ele esteja dando outro erro após o [b:7475c57dc5]except[/b:7475c57dc5].
GOSTEI 0
Amarildo
23/10/2006
Esta rotina tenho usado neste projeto de cheques. Essa rotina irá identifcar quem esta usando o banco de dados e o registro na rede bloqueando logo em seguida, possibilitando que outros usuarios aguardem a atualização dos dados para posteriormente terem acesso, espero ter ajudado alguem no forum
MODULO.TCHEQUES.IndexFieldNames := ´CHQ_NUMERO´;
if MODULO.TCHEQUES.Findkey( [Codigo] ) then
begin
if MessageDlg(´Registro já existente, deseja alterá-lo?´, mtConfirmation, [MbYes, mbNo], 0) = mrYes then
begin
try
MODULO.TCHEQUES.Edit;
except
on E: Exception do
begin
MessageBeep(0);
Str := E.Message;
if (Pos(´User:´, Str) > 0)
then
Str := Copy(Str,Pos(´User:´, Str)+5, Length(Str))
else
Str := ´Usuário desconhecido´;
FORMMENSAGEM.LabelUSUARIO.Caption := Str;
FORMMENSAGEM.SHOWMODAL;
DBEDITCONTACORRENTE.SETFOCUS;
end;
end;
end
MODULO.TCHEQUES.IndexFieldNames := ´CHQ_NUMERO´;
if MODULO.TCHEQUES.Findkey( [Codigo] ) then
begin
if MessageDlg(´Registro já existente, deseja alterá-lo?´, mtConfirmation, [MbYes, mbNo], 0) = mrYes then
begin
try
MODULO.TCHEQUES.Edit;
except
on E: Exception do
begin
MessageBeep(0);
Str := E.Message;
if (Pos(´User:´, Str) > 0)
then
Str := Copy(Str,Pos(´User:´, Str)+5, Length(Str))
else
Str := ´Usuário desconhecido´;
FORMMENSAGEM.LabelUSUARIO.Caption := Str;
FORMMENSAGEM.SHOWMODAL;
DBEDITCONTACORRENTE.SETFOCUS;
end;
end;
end
GOSTEI 0