好久没有用Delphi了,好多都忘记了,郁闷。帮我看下下面的代码有什么问题啊?
function TDataAccessModule.Login(const userName : String;
const Password : String) : Boolean;
begin
try
with ADOQuery do
begin
Close;
Sql.Clear;
Sql.Add('SELECT Password FROM admin WHERE UserID = ' + Quotedstr(userName));
Prepared;
Open;
end;
except
raise Exception.Create('Query Database Error!');
Application.MessageBox('Query Database Error!', 'SIMS', MB_OK + MB_ICONERROR);
Login := False;
Exit;
end;
if (Password = ADOQuery.FieldByName('Password').Value) then
Login := True
else
Login := False;
end;
错误如下:
---------------------------
Debugger Exception Notification
---------------------------
Project SIMS.exe raised exception class EAccessViolation with message 'Access violation at address 0046AFC9 in module 'SIMS.exe'. Read of address 0000005C'.
---------------------------
Break Continue Help
---------------------------