如题,在做窗体切换时,点击一个按钮进入下一个页面,但是弹出一个对话框,Project Project1.exe raised exception class EAccessviolation with message 'Access violation at address 0045542E in moolule 'Project1.exe.
read of address 000002F4 process stopped.use step or run to continue.
是什么意思啊?是哪里出问题了呢,窗体之间的切换代码并没有错!希望亲们给指导一下!
uses Unit2;procedure Tlogin_form.cmdokClick(Sender: TObject);
var
aname,apassword,sqlstr:string;begin
if(length(trim(name_edit.Text))>0)or(length(trim(password_edit.Text))>0)then
begin
aname:=trim(name_edit.Text);
apassword:=trim(password_edit.Text);
sqlstr:='select* from USER_PSWD where(NBXW_USER='''+aname+''')and(NBXW_PSWD='''+apassword+''')'; try
with adoquery1 do
begin
Close;
SQL.Clear;
SQL.Add(sqlstr);
Open;
if RecordCount>0 then
begin
form2:=TForm2.create(application);
form2.show; end else
begin
showmessage('请确认登录的用户名和密码是否正确!');
name_edit.SetFocus;
name_edit.SelectAll;
end;
end;
finally free;
end;
end
else
begin
showmessage('请输入登录用户名和密码!');
name_edit.SelectAll;
end;
end;end.
read of address 000002F4 process stopped.use step or run to continue.
是什么意思啊?是哪里出问题了呢,窗体之间的切换代码并没有错!希望亲们给指导一下!
uses Unit2;procedure Tlogin_form.cmdokClick(Sender: TObject);
var
aname,apassword,sqlstr:string;begin
if(length(trim(name_edit.Text))>0)or(length(trim(password_edit.Text))>0)then
begin
aname:=trim(name_edit.Text);
apassword:=trim(password_edit.Text);
sqlstr:='select* from USER_PSWD where(NBXW_USER='''+aname+''')and(NBXW_PSWD='''+apassword+''')'; try
with adoquery1 do
begin
Close;
SQL.Clear;
SQL.Add(sqlstr);
Open;
if RecordCount>0 then
begin
form2:=TForm2.create(application);
form2.show; end else
begin
showmessage('请确认登录的用户名和密码是否正确!');
name_edit.SetFocus;
name_edit.SelectAll;
end;
end;
finally free;
end;
end
else
begin
showmessage('请输入登录用户名和密码!');
name_edit.SelectAll;
end;
end;end.
end; showmessage('请输入登录用户名和密码!');
name_edit.SelectAll;你已经窗体释放了,还访问它上面的控件当然会报错了
看起来简单些排错也容易点
sqlstr:='select* from USER_PSWD where(NBXW_USER='+Quotedstr (aname)+')and(NBXW_PSWD='+Quotedstr (apassword)+')';我也学是初学的,感觉delphi用单引号作字符串有些乱,分享一下。