delphi运行登录界面是出现错误提示
procedure TForm1.BitBtn1Click(Sender: TObject);
var
password:string;
UserName:string;
QX:string;
logintimes:integer;
begin
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select 密码,权限 from f_user');
adoquery1.SQL.Add('where 姓名=:姓名');
adoquery1.Parameters.ParamByName('姓名').Value:=ComboBox1.Text;
adoquery1.Open;
if adoquery1.RecordCount>0 then
begin
password:=adoquery1.FieldValues['密码'];
if edit1.Text=password then
begin
UserName:=ComboBox1.Text;
self.Hide;
QX:=adoquery1.FieldValues['权限'];
with form2.Create(nil) do
try
ShowModal;
finally
free;
end;
end
else
begin
logintimes:=0;
logintimes:=logintimes+1;
if logintimes<3 then
begin
messagebox(handle,pchar('密码'+inttostr(logintimes)+
'次错误,请重新摄入!'),'密码错误',mb_ok or mb_iconerror);
edit1.Text:='';
edit1.SetFocus;
end
else
begin
messagebox(handle,'密码三次错误请关闭!','密码错误',mb_iconerror);
application.Terminate;
end;
end;
end;
adoquery1.Close;
freeandnil(adoquery1);
end;
错误提示
Project Project1.exe raised exception class EAccesViolation with message'Access violation at address 0048D464 in module' Project1.exe.Read of address 00000258'.Process stopped.Use Step or Run to continue.
[解决办法]
with Tform2.Create(nil) do
[解决办法]
楼上正确
另:adoquery1不是动态创建的,不需要freeandnil();
[解决办法]
adoquery1.Close;
freeandnil(adoquery1);
TForm1 form2 那个是主界面?
搞混了 也不行的 一般登录界面为主界面
[解决办法]
楼上不要误人子弟,登陆界面做主界面的也就是你吧,都是先创建登陆界面再创建主界面的
[解决办法]