FIREDAC QUERY 打开时老外遇到的一个问题?
qry.Open;
ShowMessage(BoolToString(qry.Active,True);
FunctionToDoAfter(SilentMode);
明明是打开的,却显示是FALSE.
有人回答:
有人回答是放置了TADGUIxWaitCursor 控件。
还有人回答是否设置了异步模式,在query.ResourcOptions.ComExecMode 发现这个比较靠谱:
Edit 1
.
FireDacs have four modes for commands execute. You can change it in FDQuery1.ResourceOptions.CmdExecMode. You can also set the timeout for executing command in FdQuery1.ResourceOptions.CmdExecTimeout.
The CmdExecModes are:
amBlocking (阻塞模式)-- The calling thread and GUI are blocked until an action is finished.调用query的线程和GUI被阻塞,直到一个动作完成。
amNonBlocking (非阻塞模式)-- The calling thread is blocked until an action is finished. The GUI is not blocked.调用的线程被阻塞,直到线程完成。GUI没有被阻塞。
amCancelDialog(取消对话模式) -- The calling thread and GUI are blocked until an action is finished. FireDAC shows a dialog, allowing to cancel an action.
调用query的线程和GUI被阻塞,直到一个动作完成,FireDAC 显示一个对话框,允许取消一个动作。
amAsync(异步模式) -- The calling thread and GUI are not blocked. The called method returns immediately.调用query的线程和GUI没有被阻塞,调用的方法立即返回。
You can wait while the command is executing, by checking the command state:
检查命令的状态:
FDQuery1.ResourceOptions.CmdExecMode := amAsync;
FDQuery1.Open;
while FDQuery1.Command.State = csExecuting do begin
// do something while query is executing
end;
There is 6 different command states: csInactive, csPrepared, csExecuting, csOpen, csFetching, csAborting.
浙公网安备 33010602011771号