Fórum programa não atualiza tabela quando está aberto na rede #331021
11/10/2006
0
Procurei algo sobre ele no forum, so que não encontro uma explicação completa.
E agora, quem poderar me ajudar :?: :?: :?:
Vagner.oliveira
Curtir tópico
+ 0Posts
13/10/2006
Vagner.oliveira
Gostei + 0
13/10/2006
Aloizio Castro
procedure Tdm.RefreshTables; var i : Integer; begin for i := 0 to Self.ComponentCount-1 do begin if Components[ i ] is TTable then if (Components[ i ] as TTable).Active then (Components[ i ] as TTable).Refresh; end; end; procedure Tdm.FlushTables; var i : Integer; begin for i := 0 to Self.ComponentCount-1 do begin if Components[ i ] is TTable then if (Components[ i ] as TTable).Active then begin (Components[ i ] as TTable).FlushBuffers; DbiSaveChanges((Components[ i ] as TTable).Handle); end; end; end;
E no evento de AfterPost de todas as minhas tabelas eu faço o seguinte:
FlushTables; RefreshTables;
Tente isto, além de é claro, configurar bem o BDE.
Abracos.
Gostei + 0
03/12/2006
Vagner.oliveira
- 1 button
- 1 shell change notify
- 1 label
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ShellCtrls, ExtCtrls;
type
TForm1 = class(TForm)
ShellChangeNotifier1: TShellChangeNotifier;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Shape1: TShape;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure ShellChangeNotifier1Change;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var arq:TextFile;
begin
\\ aqui eu crio o arquivo troca.txt
AssignFile(arq, ´B:\´ + ´troca.txt´); { ´b:\´ é a unidade que mapeei }
ReWrite(Arq);
Write(Arq, formatdatetime(´mm_ss´, now));
CloseFile(Arq);
end;
procedure TForm1.ShellChangeNotifier1Change;
var t:textfile;
texto:string;
begin
\\ quando o arq troca.txt é alterado ele importa o valor para o label
AssignFile(t, ´B:\´ + ´troca.txt´);
reset (t);
read(t, texto);
label1.Caption:=texto;
closefile(t);
end;
procedure TForm1.FormCreate(Sender: TObject);
var t:textfile;
texto:string;
begin
{ aqui é so um capricho, quando abre o programa ja atualiza o label }
AssignFile(t, ´B:\´ + ´troca.txt´);
reset (t);
read(t, texto);
label1.Caption:=texto;
closefile(t);
end;
end.
[size=18:3da3ec492c][b:3da3ec492c][color=red:3da3ec492c]Detalhes a serem considerados:[/color:3da3ec492c][/b:3da3ec492c][/size:3da3ec492c]
:arrow: este processo foi testado para funcionar em uma rede interna.
:arrow: é necessário mapear uma unidade em TODOS os PCs (inclusive onde está
o arquivo swap, caso ele seja executado no pc).
:arrow: o Shell Change Notify tem que ter o ´root´ com a unidade mapeada
[b:3da3ec492c][size=16:3da3ec492c]Espero que isto ajude bastante a todos e especialmente aos que sempre contribuem para o forum.[/size:3da3ec492c][/b:3da3ec492c] :P
Gostei + 0
03/12/2006
Vagner.oliveira
- 1 button
- 1 shell change notify
- 1 label
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ShellCtrls, ExtCtrls;
type
TForm1 = class(TForm)
ShellChangeNotifier1: TShellChangeNotifier;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Shape1: TShape;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure ShellChangeNotifier1Change;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var arq:TextFile;
begin
\\ aqui eu crio o arquivo troca.txt
AssignFile(arq, ´B:\´ + ´troca.txt´); { ´b:\´ é a unidade que mapeei }
ReWrite(Arq);
Write(Arq, formatdatetime(´mm_ss´, now));
CloseFile(Arq);
end;
procedure TForm1.ShellChangeNotifier1Change;
var t:textfile;
texto:string;
begin
\\ quando o arq troca.txt é alterado ele importa o valor para o label
AssignFile(t, ´B:\´ + ´troca.txt´);
reset (t);
read(t, texto);
label1.Caption:=texto;
closefile(t);
end;
procedure TForm1.FormCreate(Sender: TObject);
var t:textfile;
texto:string;
begin
{ aqui é so um capricho, quando abre o programa ja atualiza o label }
AssignFile(t, ´B:\´ + ´troca.txt´);
reset (t);
read(t, texto);
label1.Caption:=texto;
closefile(t);
end;
end.
[size=18:697ba3a55f][b:697ba3a55f][color=red:697ba3a55f]Detalhes a serem considerados:[/color:697ba3a55f][/b:697ba3a55f][/size:697ba3a55f]
:arrow: este processo foi testado para funcionar em uma rede interna.
:arrow: é necessário mapear uma unidade em TODOS os PCs (inclusive onde está
o arquivo swap, caso ele seja executado no pc).
:arrow: o Shell Change Notify tem que ter o ´root´ com a unidade mapeada
[b:697ba3a55f][size=16:697ba3a55f]Espero que isto ajude bastante a todos e especialmente aos que sempre contribuem para o forum.[/size:697ba3a55f][/b:697ba3a55f] :P
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)