我在向数据库中增加数据时,产生异常:Project Hocm_sys.exe raised exception class EAccessViolation with
message 'Access violation at address 004B40B8 in module
'Hocm_sys.exe'. Read of address 00000060'. Process stopped. Use
Step or Run to continue.然后光标就停在: "with DataM.Loginadoq do" 这一行.请各位大虾帮忙解决下,小弟在此谢过了!
message 'Access violation at address 004B40B8 in module
'Hocm_sys.exe'. Read of address 00000060'. Process stopped. Use
Step or Run to continue.然后光标就停在: "with DataM.Loginadoq do" 这一行.请各位大虾帮忙解决下,小弟在此谢过了!
procedure TLogin_M.Button1Click(Sender: TObject);
var
str : string;
begin
if (Edit1.Text = '') or (Edit2.Text = '') then
showmessage('用户名或密码不能为空!')
else
begin
with Data_M.adoqLogin do
begin
Close;
SQL.Clear;
SQL.Add('select * from user_table where user_name = ''' + trim(Edit1.Text) + '''');
ExecSQL;
end; str := Data_M.adoqLogin.fieldbyname('user_pwd').AsString;
if (str = Edit2.Text) then
showmessage('登录成功!')
else
showmessage('用户名或密码错误!');
end;
end;注:Data_M是数据模块的NAME; adoqLogin是ADOQuerry的NAME; user_table是表名; user_name和user_pwd是表中的列名;.
用OPEN不用EXECSQL
Data_M、adoqLogin创建有什么需要注意的吗?
用Open也不行!
请大虾指点!谢谢!
主程序如下所示:
begin
Application.Initialize;
Application.CreateForm(TData_M, Data_M);
Application.CreateForm(TLogin_M, Login_M);
Application.Run;
end.不知道这样是不是对的!但我运行时会提示登录失败!