急急,执行时出现'Error Creating cursor handle'是什么原因?(20分)

  • 主题发起人 主题发起人 ahwui
  • 开始时间 开始时间
A

ahwui

Unregistered / Unconfirmed
GUEST, unregistred user!
我正在做一个修改密码的程序,前面的验证等都没错,
但在更新数据库之后就出现如下提示
“Project abc.exe raised execption class ENoResultSet with message 'Error Creating cursor handle'.”
数据库更新操作已经成功。
部分源程序:
procedure TPasswordForm.Button1Click(Sender: TObject);
var username,UPwd,UPwdNew,UPwdConf:string;
sqlResult:integer;
begin
username:='bruce';
UPwd:=PwdNow.text;
UPwdNew:=PwdNew.text;
UPwdConf:=PwdConf.text;


if (UPwd = '') or (UPwdNew = '') or (UPwdConf = '') or (UPwdNew <> UPwdConf) then
begin
MessageDlg('输入不正确。', mtInformation,[mbOk], 0);
exit;
end;

Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('select count(EmployeeID) from tblValidate where UserName='''+username+''' and Pswd='''+UPwd+'''');
Query1.Open;
sqlResult:=StrToInt(Query1.Fields[0].AsString);

if sqlResult=0 then
begin
MessageDlg('输入的现用密码错误!', mtInformation,[mbOk], 0);
PwdNow.SetFocus;
exit;
end
else
begin
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('update tblValidate set Pswd='''+UPwdNew+''' where UserName='''+username+'''');
Query1.Open;

MessageDlg('密码修改成功!', mtInformation,[mbOk], 0);
end;

end;

 
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('update tblValidate set Pswd='''+UPwdNew+''' where UserName='''+username+'''');
Query1.Open; //该句错误,update语句没有游标返回

该为
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('update tblValidate set Pswd='''+UPwdNew+''' where UserName='''+username+'''');
Query1.execsql;
 
谢谢 Brave
问题解决啦。
 
后退
顶部