H
hewhl
Unregistered / Unconfirmed
GUEST, unregistred user!
在dll的frmlgn中有Adoconnection,在host中用dll中的frmfgn传递的是application.handle,可是把frmlgn关闭时老是报地址错,我在关闭前以把adoconnection.Connected:=false,
frmlgn上还有两个动态创的adoquery也closed了!请问这怎么处理!
CODE:
function Tfrmlgn.login(name,psw:string):boolean;
var
qlgn:tadoquery;
begin
try
qlgn:=tadoquery.Create(nil);
qlgn.Connection:=adocn;
qlgn.Active:=false;
qlgn.SQL.Clear ;
qlgn.sql.Text:='select username,password from usertbl where username=:name and password=sw ';
qlgn.Parameters.ParamValues['name']:=name;
qlgn.Parameters.ParamValues['psw']:=psw;
qlgn.Active:=true;
if qlgn.RecordCount >0 then
result:=false
else
result:=true;
finally
qlgn.Close;[8D]
end;
end;
procedure Tfrmlgn.BitBtn1Click(Sender: TObject);
begin
try
if login(user.Text,psw.Text) then
begin
messagebox(application.handle,'密码不正确!','警告',mb_Iconinformation);
psw.Text:='';
psw.SetFocus;
end
else begin
adocn.Connected:=false;
adocn.Free
frmlgn.close ;
frmsplash:=tfrmsplash.Create(nil);
frmsplash.ShowModal;
frmsplash.Update ;
end;
finally
end;
end;
procedure Tfrmlgn.FormCreate(Sender: TObject);
var
tlgn:tadoquery;
begin
user.text:='';
psw.text:='';
tlgn:=tadoquery.Create(nil);
tlgn.Connection:=adocn;
tlgn.Active :=false;
tlgn.SQL.Text :='select username from usertbl';
tlgn.Active :=true;
while not tlgn.Eof do
begin
user.Items.add(tlgn.FieldValues['username']);
tlgn.Next;
end
user.ItemIndex :=0;
tlgn.close;
end;
请指出错在哪里??????
frmlgn上还有两个动态创的adoquery也closed了!请问这怎么处理!
CODE:
function Tfrmlgn.login(name,psw:string):boolean;
var
qlgn:tadoquery;
begin
try
qlgn:=tadoquery.Create(nil);
qlgn.Connection:=adocn;
qlgn.Active:=false;
qlgn.SQL.Clear ;
qlgn.sql.Text:='select username,password from usertbl where username=:name and password=sw ';
qlgn.Parameters.ParamValues['name']:=name;
qlgn.Parameters.ParamValues['psw']:=psw;
qlgn.Active:=true;
if qlgn.RecordCount >0 then
result:=false
else
result:=true;
finally
qlgn.Close;[8D]
end;
end;
procedure Tfrmlgn.BitBtn1Click(Sender: TObject);
begin
try
if login(user.Text,psw.Text) then
begin
messagebox(application.handle,'密码不正确!','警告',mb_Iconinformation);
psw.Text:='';
psw.SetFocus;
end
else begin
adocn.Connected:=false;
adocn.Free
frmlgn.close ;
frmsplash:=tfrmsplash.Create(nil);
frmsplash.ShowModal;
frmsplash.Update ;
end;
finally
end;
end;
procedure Tfrmlgn.FormCreate(Sender: TObject);
var
tlgn:tadoquery;
begin
user.text:='';
psw.text:='';
tlgn:=tadoquery.Create(nil);
tlgn.Connection:=adocn;
tlgn.Active :=false;
tlgn.SQL.Text :='select username from usertbl';
tlgn.Active :=true;
while not tlgn.Eof do
begin
user.Items.add(tlgn.FieldValues['username']);
tlgn.Next;
end
user.ItemIndex :=0;
tlgn.close;
end;
请指出错在哪里??????