即使ApplyUpdates在try ...除外,仍然会出现错误弹出窗口 [英] Still get error popup even when ApplyUpdates is inside try...except

查看:437
本文介绍了即使ApplyUpdates在try ...除外,仍然会出现错误弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

找到解决方案,请参阅我的评论

D5,odbc到mysql数据库

D5, odbc to mysql database

此代码:

  with QryCmdPerf do begin
    Close;
    ParamByName('ACCTID').AsInteger:= AcctId;
    ParamByName('FROMDT').AsString:= MySQLDate(FromDt);
    ParamByName('TODT').AsString:= MySQLDate(ToDt);
    Open;
    first;
    try
      edit;
      FieldByName('PnL').AsFloat:= 97979;
      ApplyUpdates;
    except
      close;
    end;
  end;    // with

(特别是ApplyUpdates)会导致弹出窗口出现,文本更新失败如果PnL字段已经具有值97979,显然是因为这个代码:

(specifically the "ApplyUpdates") causes a popup to appear with the text "Update Failed" if the PnL field already has the value 97979, evidently because of this code:

procedure TUpdateSQL.ExecSQL(UpdateKind: TUpdateKind);
begin
  with Query[UpdateKind] do
  begin
    Prepare;
    ExecSQL;
    if RowsAffected <> 1 then DatabaseError(SUpdateFailed);
  end;
end;

无论如何,我希望能够发布ApplyUpdates,如果没有更新,就不用担心弹出窗口。但是如果try ... except不起作用,那么会是什么?

in DBTables.pas. Anyway, I want to be able to issue ApplyUpdates, and not have to worry about a popup if it doesn't do any updating. But if "try...except" doesn't work, what will?

TIA

推荐答案

简单的答案是,你必须为OnUpdateError设置一个事件处理程序,或者没有数量的try ... except块将阻止弹出窗口。很长一段时间的答案似乎是odbc的错误。可以在这里: http://www.codeupload.com/3919 ,任何想要采取看它。你可以跳过MySQL的东西,任何odbc数据库都会做。

The short answer is, you have to set up an eventhandler for OnUpdateError or no amount of "try...except" blocks will block the popup. The long answer is it appears to be a bug with odbc. The repro is here: http://www.codeupload.com/3919 for anyone who wants to take a look at it. You can skip the MySQL stuff, any odbc database will do.

这篇关于即使ApplyUpdates在try ...除外,仍然会出现错误弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆