N
nq961
Unregistered / Unconfirmed
GUEST, unregistred user!
看多线程快半个月了,还是一塌糊涂,谁能帮帮我呢?
帮我把下面的线程改成多线程呢?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB;
type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
filename,temp,t1,t2,t3,t4:string;
f:textfile;
begin
filename:='c:/year.txt';
assignfile(f,filename);
reset(f);
while not eof(f)do
begin
readln(f,temp);
if pos(' ',temp)>0 then
begin
t1:=copy(temp,1,pos(' ',temp)-1);
temp:=copy(temp,pos(' ',temp)+1,length(temp)-pos(' ',temp));
end;
if pos(' ',temp)>0 then
begin
t2:=copy(temp,1,pos(' ',temp)-1);
temp:=copy(temp,pos(' ',temp)+1,length(temp)-pos(' ',temp));
end;
if pos(' ',temp)>0 then
begin
t3:=copy(temp,1,pos(' ',temp)-1);
temp:=copy(temp,pos(' ',temp)+1,length(temp)-pos(' ',temp));
end;
if pos(' ',temp)>0 then
begin
t4:=copy(temp,1,pos(' ',temp)-1);
temp:=copy(temp,pos(' ',temp)+1,length(temp)-pos(' ',temp));
end
else
t4:=temp;
with adoquery1do
begin
close;
sql.Clear;
sql.Add('insert into biao (nam,pwd,lx,ly) values a,:b,:c,:d)');
parameters.ParamByName('a').Value:=t1;
parameters.ParamByName('b').Value:=t2;
parameters.ParamByName('c').Value:=t3;
parameters.ParamByName('d').Value:=t4;
execsql;
end;
end;
end;
end.
year.txt 文件格式如下:
11.2 23.2 22.4 4l.2
34.2 23.2 35.3 33.3
45.5 53.6 66.4 46.4
42.4 64.3 75.4 42.4
帮我把下面的线程改成多线程呢?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB;
type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
filename,temp,t1,t2,t3,t4:string;
f:textfile;
begin
filename:='c:/year.txt';
assignfile(f,filename);
reset(f);
while not eof(f)do
begin
readln(f,temp);
if pos(' ',temp)>0 then
begin
t1:=copy(temp,1,pos(' ',temp)-1);
temp:=copy(temp,pos(' ',temp)+1,length(temp)-pos(' ',temp));
end;
if pos(' ',temp)>0 then
begin
t2:=copy(temp,1,pos(' ',temp)-1);
temp:=copy(temp,pos(' ',temp)+1,length(temp)-pos(' ',temp));
end;
if pos(' ',temp)>0 then
begin
t3:=copy(temp,1,pos(' ',temp)-1);
temp:=copy(temp,pos(' ',temp)+1,length(temp)-pos(' ',temp));
end;
if pos(' ',temp)>0 then
begin
t4:=copy(temp,1,pos(' ',temp)-1);
temp:=copy(temp,pos(' ',temp)+1,length(temp)-pos(' ',temp));
end
else
t4:=temp;
with adoquery1do
begin
close;
sql.Clear;
sql.Add('insert into biao (nam,pwd,lx,ly) values a,:b,:c,:d)');
parameters.ParamByName('a').Value:=t1;
parameters.ParamByName('b').Value:=t2;
parameters.ParamByName('c').Value:=t3;
parameters.ParamByName('d').Value:=t4;
execsql;
end;
end;
end;
end.
year.txt 文件格式如下:
11.2 23.2 22.4 4l.2
34.2 23.2 35.3 33.3
45.5 53.6 66.4 46.4
42.4 64.3 75.4 42.4