begin
if (edit1.Text<>'')and(edit3.Text<>'')then
begin
ADOQuery1.SQL.Add('select * from usepass where 帐号='''+edit1.Text+''' and 密码='''+edit3.Text+'''');
ADOQuery1.Open;
if ADOQuery1.Eof then
begin
messagebox(handle,'用户和密码错误!','出错提示',mb_iconinformation+mb_ok);
edit1.SetFocus;
end
else
begin
if not(edit4.text=edit5.Text) then exit;
adoquery1.FieldByName('帐号').AsString:=edit2.text;
adoquery1.FieldByName('密码').AsString:=edit3.Text;
if messagebox(handle,'确定后修改用户和密码','信息提示',mb_iconinformation+mb_yesno)=idno then exit;
showmessage(pchar('用户名为: '+edit2.Text+' 密码为: '+edit4.Text));
adoquery1.Post;
end
end
else
begin
showmessage('原用户名和旧密码不能为空!');
edit1.SetFocus;
end
end;
运行后没错,但修改时就出错:adoquery1.FieldByName('帐号').AsString:=edit2.text;
adoquery1.FieldByName('密码').AsString:=edit3.Text;
adoquery1.Post;
请各路大虾帮我改改,谢谢!
if (edit1.Text<>'')and(edit3.Text<>'')then
begin
ADOQuery1.SQL.Add('select * from usepass where 帐号='''+edit1.Text+''' and 密码='''+edit3.Text+'''');
ADOQuery1.Open;
if ADOQuery1.Eof then
begin
messagebox(handle,'用户和密码错误!','出错提示',mb_iconinformation+mb_ok);
edit1.SetFocus;
end
else
begin
if not(edit4.text=edit5.Text) then exit;
adoquery1.FieldByName('帐号').AsString:=edit2.text;
adoquery1.FieldByName('密码').AsString:=edit3.Text;
if messagebox(handle,'确定后修改用户和密码','信息提示',mb_iconinformation+mb_yesno)=idno then exit;
showmessage(pchar('用户名为: '+edit2.Text+' 密码为: '+edit4.Text));
adoquery1.Post;
end
end
else
begin
showmessage('原用户名和旧密码不能为空!');
edit1.SetFocus;
end
end;
运行后没错,但修改时就出错:adoquery1.FieldByName('帐号').AsString:=edit2.text;
adoquery1.FieldByName('密码').AsString:=edit3.Text;
adoquery1.Post;
请各路大虾帮我改改,谢谢!
if (edit1.Text<>'')and(edit3.Text<>'')then
begin
ADOQuery1.close;//在此处加上这句看看行不行
ADOQuery1.SQL.Add('select * from usepass where 帐号='''+edit1.Text+''' and 密码='''+edit3.Text+'''');
ADOQuery1.Open;
if ADOQuery1.Eof then
begin
messagebox(handle,'用户和密码错误!','出错提示',mb_iconinformation+mb_ok);
edit1.SetFocus;
end
else
begin
if not(edit4.text=edit5.Text) then exit;
adoquery1.FieldByName('帐号').AsString:=edit2.text;
adoquery1.FieldByName('密码').AsString:=edit3.Text;
if messagebox(handle,'确定后修改用户和密码','信息提示',mb_iconinformation+mb_yesno)=idno then exit;
showmessage(pchar('用户名为: '+edit2.Text+' 密码为: '+edit4.Text));
adoquery1.Post;
end
end
else
begin
showmessage('原用户名和旧密码不能为空!');
edit1.SetFocus;
end
end;
提示:Project sys.exe raised exception class EDatabaseError with message 'ADOQuery1:Dataset not in edit or isert mode'. Process stopped.Use Step or Run to continue.
view CPU Windows
单击确定后:
adoquery1.FieldByName('帐号').AsString:=edit2.text;
adoquery1.FieldByName('密码').AsString:=edit3.Text;
adoquery1.Post;
这三条语句错误!
if (edit1.Text<>'')and(edit3.Text<>'')then
begin
ADOQuery1.SQL.Add('select * from usepass where 帐号='''+edit1.Text+''' and 密码='''+edit3.Text+'''');
ADOQuery1.Open;
if ADOQuery1.Eof then
begin
messagebox(handle,'用户和密码错误!','出错提示',mb_iconinformation+mb_ok);
edit1.SetFocus;
end
else
begin
if not(edit4.text=edit5.Text) then exit;
adoquery1.edit;//////////////////////////////////////注意:我加的!!!!!!!!!!!!!!!!
adoquery1.FieldByName('帐号').AsString:=edit2.text;
adoquery1.FieldByName('密码').AsString:=edit3.Text;
if messagebox(handle,'确定后修改用户和密码','信息提示',mb_iconinformation+mb_yesno)=idno then exit;
showmessage(pchar('用户名为: '+edit2.Text+' 密码为: '+edit4.Text));
adoquery1.Post;
end
end
else
begin
showmessage('原用户名和旧密码不能为空!');
edit1.SetFocus;
end
end;
错在那里!
...
adoquery1.post;