Windows窗体应用程序显示OBDC DB2连接的查询执行/检索时间

时间:2015-08-17 17:51:01

标签: c# winforms visual-studio-2010 db2

我需要进度条或状态消息来显示执行查询时间。现在我的应用程序只冻结,我无法显示已经过了多少时间以及查询执行的位置(执行与检索)

我对此没有太多了解,而且我不知道它是否可能因为冻结,是否有办法取消查询?

谢谢!

1 个答案:

答案 0 :(得分:1)

要在执行长时间运行的查询时拥有未冻结的应用程序,您需要在单独的线程上执行它。尝试使用 Rules useless in parser due to conflicts 7 expr: simp_expr relop simp_expr 9 simp_expr: simp_expr addop term 11 term: term mulop factor 16 factor: not factor State 12 conflicts: 1 shift/reduce State 13 conflicts: 2 shift/reduce State 14 conflicts: 1 shift/reduce State 17 conflicts: 2 reduce/reduce State 20 conflicts: 6 reduce/reduce State 25 conflicts: 1 shift/reduce State 26 conflicts: 2 shift/reduce, 6 reduce/reduce State 27 conflicts: 1 shift/reduce, 6 reduce/reduce State 28 conflicts: 6 reduce/reduce Grammar 0 $accept: stmt_list $end 1 stmt_list: stmt 2 | stmt_list ';' stmt 3 stmt: var assignop expr 4 var: id 5 | id '[' expr ']' 6 expr: simp_expr 7 | simp_expr relop simp_expr 8 simp_expr: term 9 | simp_expr addop term 10 term: factor 11 | term mulop factor 12 factor: id 13 | num 14 | expr 15 | id '[' expr ']' 16 | not factor Terminals, with rules where they appear $end (0) 0 ';' (59) 2 '[' (91) 5 15 ']' (93) 5 15 error (256) id (258) 4 5 12 15 num (259) 13 relop (260) 7 mulop (261) 11 addop (262) 9 assignop (263) 3 not (264) 16 Nonterminals, with rules where they appear $accept (13) on left: 0 stmt_list (14) on left: 1 2, on right: 0 2 stmt (15) on left: 3, on right: 1 2 var (16) on left: 4 5, on right: 3 expr (17) on left: 6 7, on right: 3 5 14 15 simp_expr (18) on left: 8 9, on right: 6 7 9 term (19) on left: 10 11, on right: 8 9 11 factor (20) on left: 12 13 14 15 16, on right: 10 11 16 state 0 0 $accept: . stmt_list $end 1 stmt_list: . stmt 2 | . stmt_list ';' stmt 3 stmt: . var assignop expr 4 var: . id 5 | . id '[' expr ']' id shift, and go to state 1 stmt_list go to state 2 stmt go to state 3 var go to state 4 state 1 4 var: id . [assignop] 5 | id . '[' expr ']' '[' shift, and go to state 5 $default reduce using rule 4 (var) state 2 0 $accept: stmt_list . $end 2 stmt_list: stmt_list . ';' stmt $end shift, and go to state 6 ';' shift, and go to state 7 state 3 1 stmt_list: stmt . $default reduce using rule 1 (stmt_list) state 4 3 stmt: var . assignop expr assignop shift, and go to state 8 state 5 5 var: id '[' . expr ']' 6 expr: . simp_expr 7 | . simp_expr relop simp_expr 8 simp_expr: . term 9 | . simp_expr addop term 10 term: . factor 11 | . term mulop factor 12 factor: . id 13 | . num 14 | . expr 15 | . id '[' expr ']' 16 | . not factor id shift, and go to state 9 num shift, and go to state 10 not shift, and go to state 11 expr go to state 12 simp_expr go to state 13 term go to state 14 factor go to state 15 state 6 0 $accept: stmt_list $end . $default accept state 7 2 stmt_list: stmt_list ';' . stmt 3 stmt: . var assignop expr 4 var: . id 5 | . id '[' expr ']' id shift, and go to state 1 stmt go to state 16 var go to state 4 state 8 3 stmt: var assignop . expr 6 expr: . simp_expr 7 | . simp_expr relop simp_expr 8 simp_expr: . term 9 | . simp_expr addop term 10 term: . factor 11 | . term mulop factor 12 factor: . id 13 | . num 14 | . expr 15 | . id '[' expr ']' 16 | . not factor id shift, and go to state 9 num shift, and go to state 10 not shift, and go to state 11 expr go to state 17 simp_expr go to state 13 term go to state 14 factor go to state 15 state 9 12 factor: id . [$end, relop, mulop, addop, ';', ']'] 15 | id . '[' expr ']' '[' shift, and go to state 18 $default reduce using rule 12 (factor) state 10 13 factor: num . $default reduce using rule 13 (factor) state 11 6 expr: . simp_expr 7 | . simp_expr relop simp_expr 8 simp_expr: . term 9 | . simp_expr addop term 10 term: . factor 11 | . term mulop factor 12 factor: . id 13 | . num 14 | . expr 15 | . id '[' expr ']' 16 | . not factor 16 | not . factor id shift, and go to state 9 num shift, and go to state 10 not shift, and go to state 11 expr go to state 19 simp_expr go to state 13 term go to state 14 factor go to state 20 state 12 5 var: id '[' expr . ']' 14 factor: expr . [relop, mulop, addop, ']'] ']' shift, and go to state 21 ']' [reduce using rule 14 (factor)] $default reduce using rule 14 (factor) state 13 6 expr: simp_expr . [$end, relop, mulop, addop, ';', ']'] 7 | simp_expr . relop simp_expr 9 simp_expr: simp_expr . addop term relop shift, and go to state 22 addop shift, and go to state 23 relop [reduce using rule 6 (expr)] addop [reduce using rule 6 (expr)] $default reduce using rule 6 (expr) state 14 8 simp_expr: term . [$end, relop, mulop, addop, ';', ']'] 11 term: term . mulop factor mulop shift, and go to state 24 mulop [reduce using rule 8 (simp_expr)] $default reduce using rule 8 (simp_expr) state 15 10 term: factor . $default reduce using rule 10 (term) state 16 2 stmt_list: stmt_list ';' stmt . $default reduce using rule 2 (stmt_list) state 17 3 stmt: var assignop expr . [$end, ';'] 14 factor: expr . [$end, relop, mulop, addop, ';'] $end reduce using rule 3 (stmt) $end [reduce using rule 14 (factor)] ';' reduce using rule 3 (stmt) ';' [reduce using rule 14 (factor)] $default reduce using rule 14 (factor) state 18 6 expr: . simp_expr 7 | . simp_expr relop simp_expr 8 simp_expr: . term 9 | . simp_expr addop term 10 term: . factor 11 | . term mulop factor 12 factor: . id 13 | . num 14 | . expr 15 | . id '[' expr ']' 15 | id '[' . expr ']' 16 | . not factor id shift, and go to state 9 num shift, and go to state 10 not shift, and go to state 11 expr go to state 25 simp_expr go to state 13 term go to state 14 factor go to state 15 state 19 14 factor: expr . $default reduce using rule 14 (factor) state 20 10 term: factor . [$end, relop, mulop, addop, ';', ']'] 16 factor: not factor . [$end, relop, mulop, addop, ';', ']'] $end reduce using rule 10 (term) $end [reduce using rule 16 (factor)] relop reduce using rule 10 (term) relop [reduce using rule 16 (factor)] mulop reduce using rule 10 (term) mulop [reduce using rule 16 (factor)] addop reduce using rule 10 (term) addop [reduce using rule 16 (factor)] ';' reduce using rule 10 (term) ';' [reduce using rule 16 (factor)] ']' reduce using rule 10 (term) ']' [reduce using rule 16 (factor)] $default reduce using rule 10 (term) state 21 5 var: id '[' expr ']' . $default reduce using rule 5 (var) state 22 6 expr: . simp_expr 7 | . simp_expr relop simp_expr 7 | simp_expr relop . simp_expr 8 simp_expr: . term 9 | . simp_expr addop term 10 term: . factor 11 | . term mulop factor 12 factor: . id 13 | . num 14 | . expr 15 | . id '[' expr ']' 16 | . not factor id shift, and go to state 9 num shift, and go to state 10 not shift, and go to state 11 expr go to state 19 simp_expr go to state 26 term go to state 14 factor go to state 15 state 23 6 expr: . simp_expr 7 | . simp_expr relop simp_expr 8 simp_expr: . term 9 | . simp_expr addop term 9 | simp_expr addop . term 10 term: . factor 11 | . term mulop factor 12 factor: . id 13 | . num 14 | . expr 15 | . id '[' expr ']' 16 | . not factor id shift, and go to state 9 num shift, and go to state 10 not shift, and go to state 11 expr go to state 19 simp_expr go to state 13 term go to state 27 factor go to state 15 state 24 6 expr: . simp_expr 7 | . simp_expr relop simp_expr 8 simp_expr: . term 9 | . simp_expr addop term 10 term: . factor 11 | . term mulop factor 11 | term mulop . factor 12 factor: . id 13 | . num 14 | . expr 15 | . id '[' expr ']' 16 | . not factor id shift, and go to state 9 num shift, and go to state 10 not shift, and go to state 11 expr go to state 19 simp_expr go to state 13 term go to state 14 factor go to state 28 state 25 14 factor: expr . [relop, mulop, addop, ']'] 15 | id '[' expr . ']' ']' shift, and go to state 29 ']' [reduce using rule 14 (factor)] $default reduce using rule 14 (factor) state 26 6 expr: simp_expr . [$end, relop, mulop, addop, ';', ']'] 7 | simp_expr . relop simp_expr 7 | simp_expr relop simp_expr . [$end, relop, mulop, addop, ';', ']'] 9 simp_expr: simp_expr . addop term relop shift, and go to state 22 addop shift, and go to state 23 $end reduce using rule 6 (expr) $end [reduce using rule 7 (expr)] relop [reduce using rule 6 (expr)] relop [reduce using rule 7 (expr)] mulop reduce using rule 6 (expr) mulop [reduce using rule 7 (expr)] addop [reduce using rule 6 (expr)] addop [reduce using rule 7 (expr)] ';' reduce using rule 6 (expr) ';' [reduce using rule 7 (expr)] ']' reduce using rule 6 (expr) ']' [reduce using rule 7 (expr)] $default reduce using rule 6 (expr) state 27 8 simp_expr: term . [$end, relop, mulop, addop, ';', ']'] 9 | simp_expr addop term . [$end, relop, mulop, addop, ';', ']'] 11 term: term . mulop factor mulop shift, and go to state 24 $end reduce using rule 8 (simp_expr) $end [reduce using rule 9 (simp_expr)] relop reduce using rule 8 (simp_expr) relop [reduce using rule 9 (simp_expr)] mulop [reduce using rule 8 (simp_expr)] mulop [reduce using rule 9 (simp_expr)] addop reduce using rule 8 (simp_expr) addop [reduce using rule 9 (simp_expr)] ';' reduce using rule 8 (simp_expr) ';' [reduce using rule 9 (simp_expr)] ']' reduce using rule 8 (simp_expr) ']' [reduce using rule 9 (simp_expr)] $default reduce using rule 8 (simp_expr) state 28 10 term: factor . [$end, relop, mulop, addop, ';', ']'] 11 | term mulop factor . [$end, relop, mulop, addop, ';', ']'] $end reduce using rule 10 (term) $end [reduce using rule 11 (term)] relop reduce using rule 10 (term) relop [reduce using rule 11 (term)] mulop reduce using rule 10 (term) mulop [reduce using rule 11 (term)] addop reduce using rule 10 (term) addop [reduce using rule 11 (term)] ';' reduce using rule 10 (term) ';' [reduce using rule 11 (term)] ']' reduce using rule 10 (term) ']' [reduce using rule 11 (term)] $default reduce using rule 10 (term) state 29 15 factor: id '[' expr ']' . $default reduce using rule 15 (factor) 。它可以使用BackgroundWorker。有两种情况:

1 - 您有一个查询可以批量修改某个表,但它在DB服务器上运行很长时间。在这种情况下,如果可能,您可以(并且此处也有多个方案),将批处理日志写入某个表。您可以创建临时触发器和临时表查询目标表。触发器将在处理记录时更新临时表。在后台工作程序中编写SQL查询以查询临时表并查看记录的行数。这样做直到工作标记为" DONE" (在同一个临时表中)

2 - 在这种情况下,很容易跟踪进度,因为在这里您在代码中执行了一行SQL。所以你知道你有多少更新,并且可以精确地告诉你,例如"处理5和1000#34;。在您的后台工作人员中,您将在ReportProgress中完成此项工作,并且在每次拨打数据电话时,您都会调用DoWork

如何实施ReportProgress您可以在线找到1000个示例。对于场景#2,这几乎就是它。对于场景#1,它取决于您的操作。可能有10种不同的方法来实现它。但主要逻辑仍然存在 - 一个单独的线程正在跟踪进度抛出一些设备(在本例中为表)。