思路是一样的啊eg:插100条记录:for i := 0 to 99 do begin ... Query1.SQL.Add('insert into ...'); ProgressBar1.Position := i; end;
function TForm1.UpdateList_Rcyk: Boolean; begin Result:=False; with Qy_Update do begin Close; SQL.Clear; SQL.Add('update JxList_Rcyk '); SQL.Add('set Yj_Yjj=Yj_Yjj+Wj_Yjj,Yj_Fy=Yj_Fy+Wj_Fy '); SQL.Add(',Wj_Yjj=0,Wj_Fy=0 '); SQL.Add('where (time_cy is not null or time_cy<>0) '); SQL.Add('and code_Jzzt=''0'' '); SQL.Add('and (Yj_Yjj is null or Yj_Yjj=0) '); ExecSQL; Result:=True; Close end; end; 代码如上,如何实现?
但是要让用户知道他做完了这件事----------------------------------就这个目的可以这样:(^_^) function TForm1.UpdateList_Rcyk: Boolean; begin Result:=False; with Qy_Update do begin Close; SQL.Clear; SQL.Add('update JxList_Rcyk '); SQL.Add('set Yj_Yjj=Yj_Yjj+Wj_Yjj,Yj_Fy=Yj_Fy+Wj_Fy '); SQL.Add(',Wj_Yjj=0,Wj_Fy=0 '); SQL.Add('where (time_cy is not null or time_cy<>0) '); SQL.Add('and code_Jzzt=''0'' '); SQL.Add('and (Yj_Yjj is null or Yj_Yjj=0) '); ExecSQL; ProgressBar1.Position := 100; Result:=True; Close end; end;
...
给个例子unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;type
TForm1 = class(TForm)
ListView1: TListView;
ProgressBar1: TProgressBar;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
NewItem: TListItem;
begin
for i := 0 to 99 do
begin
NewItem := ListView1.Items.Add;
NewItem.Caption := 'aaa';
ProgressBar1.Position := i;
end;
end;end.
请问如果我要向数据库中插入或更新(Query)数据时,怎样表示她的进度?
begin
...
Query1.SQL.Add('insert into ...');
ProgressBar1.Position := i;
end;
begin
Result:=False;
with Qy_Update do
begin
Close;
SQL.Clear;
SQL.Add('update JxList_Rcyk ');
SQL.Add('set Yj_Yjj=Yj_Yjj+Wj_Yjj,Yj_Fy=Yj_Fy+Wj_Fy ');
SQL.Add(',Wj_Yjj=0,Wj_Fy=0 ');
SQL.Add('where (time_cy is not null or time_cy<>0) ');
SQL.Add('and code_Jzzt=''0'' ');
SQL.Add('and (Yj_Yjj is null or Yj_Yjj=0) ');
ExecSQL;
Result:=True;
Close
end;
end;
代码如上,如何实现?
这个过程很慢吗?
function TForm1.UpdateList_Rcyk: Boolean;
begin
Result:=False;
with Qy_Update do
begin
Close;
SQL.Clear;
SQL.Add('update JxList_Rcyk ');
SQL.Add('set Yj_Yjj=Yj_Yjj+Wj_Yjj,Yj_Fy=Yj_Fy+Wj_Fy ');
SQL.Add(',Wj_Yjj=0,Wj_Fy=0 ');
SQL.Add('where (time_cy is not null or time_cy<>0) ');
SQL.Add('and code_Jzzt=''0'' ');
SQL.Add('and (Yj_Yjj is null or Yj_Yjj=0) ');
ExecSQL;
ProgressBar1.Position := 100;
Result:=True;
Close
end;
end;