|
|
|
ADO - баг или нет?
|
|||
|---|---|---|---|
|
#18+
Заранее извиняюсь, что пишу по-английски, письмо было отправлено в Microsoft и ни ответа... ни привета: вкратце, при доступу к БД через ADO не работают таймауты выполнения команд. As far as we have Microsoft Products Support, we need your elucidations on ADO technology usage (we have serious troubles with it and we guess if those are ADO bugs). We are using ActiveX Data Objects to retrieve data and to execute stored procedures in Microsoft SQL Server 2000 and Sybase databases. Some stored procedures are executed for a long time. We use ADO.Command objects to execute stored procedures. We want to stop long-time procedures executions when a fixed timeout expires. According to MSDN (ms-help://MS.VSCC/MS.MSDNVS/ado270/htm/mdprocommandtimeout.htm), there’s a special property named CommandTimeout at ADO.Command object that can be used to achieve this goal: «Indicates how long to wait while executing a command before terminating the attempt and generating an error.». The same property can be found at ADO.Connection object. ADO.Command object also contains method Cancel (ms-help://MS.VSCC/MS.MSDNVS/ado270/htm/mdmthadocancel.htm): «Cancel method allows to interrupt ADO command, executed asynchronously.» We use several ways to access databases: OLE DB ODBC OLEDB through ODBC We use two ways to interrupt long executed command: using CommandTimout property of ADOCommand and ADOConnection objects. using Cancel method of ADOCommand object (asynchronous execution) We use 3 types of connection strings: For MS SQL Server: OLEDB: "Provider=SQLOLEDB.1;Password=pwd;Persist Security Info=True;User ID=sa;Initial Catalog=pubs;Data Source=TESTPC " ODBC: "Dsn=Pubs;uid=sa;pwd=pwd;app=TstApp;wsid=PANTJULIN" OLEDB through ODBC: "Provider=MSDASQL.1;Password=pwd;Persist Security Info=True;User ID=sa;Data Source=Pubs;Initial Catalog=pubs" For Sybase: OLEDB: "Provider=Sybase.ASEOLEDBProvider.2;Initial Catalog=tstdb;Password=tstpwd;User ID=tstusr;Data Source=tstdb;Persist Security Info=True;Application Name=TstApp" ODBC: "Dsn=tstdb;uid=tstusr;pwd= tstpwd;na=207.1.175.99,4100;db= tstdb" OLEDB through ODBC: "Provider=MSDASQL.1;Password=tstpwd;Persist Security Info=True;User ID=tstusr;Data Source=tstdb;Initial Catalog= tstdb" Procedure dbo.testdbadapter is used to model a long-time one. It consists of a long loop where incremental values are inserted into temporary table. It helps to estimate when the procedure was interrupted (just examining the last table value): Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. We use following code to execute dbadaptertest procedure (code given for database access via ODBC, other methods differ from this by connection strings only, connection strings are specified above): Using CommandTimeout property: Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99. 100. 101. 102. 103. 104. 105. 106. 107. 108. 109. 110. 111. 112. 113. 114. 115. 116. 117. 118. 119. 120. 121. 122. 123. 124. 125. 126. ADOConnection object: Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99. 100. 101. 102. 103. 104. 105. 106. 107. 108. 109. 110. 111. 112. 113. 114. 115. Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99. 100. 101. 102. 103. 104. 105. 106. 107. 108. 109. 110. 111. 112. 113. 114. 115. 116. 117. 118. 119. 120. 121. 122. 123. 124. 125. 126. 127. 128. 129. 130. 131. 132. 133. 134. 135. 136. 137. 138. 139. 140. 141. 142. 143. 144. 145. 146. 147. 148. 149. 150. 151. 152. 153. 154. 155. However, we were surprised since we had examined the results of the experiment described above: 1. Access with OLE DB: Conclusions: 1. CommandTimeout is ignored for ADODB:Command and ADODB:Connection objects (MS SQL, Sybase) 2. Exception occurs in Execute method (asynchronous execution). It looks rather strange as exception is thrown to another thread as GUI (Application has window) works when exception occurs. (MS SQL Server). 3. Cancel method holds the application until the procedure is not executed completely. When Execute method finishes its execution control is returned to the application (GUI) (Sybase). 2. Access with ODBC: Conclusions: 1. CommandTimeout is ignored for ADODB:Command and ADODB:Connection objects (MS SQL, Sybase) 2. Execute method (asynchronous execution) works correctly (MS SQL и Sybase). Procedure is interrupted. 3. Access with OLEDB provider for ODBC: Conclusions: 1. CommandTimeout is ignored for ADODB:Command and ADODB:Connection objects (MS SQL, Sybase) 2. Execute method (asynchronous execution) works correctly (MS SQL и Sybase). Procedure is interrupted. We use following versions of drivers/products: ADO 2.7 (2.81.1117.0 as it is described in typelib properties of msado27.tlb file) ODBC Driver Manager: 3.525.1117 ODBC: Sybase ACE ODBC Driver 4.20.00.67 Microsoft SQL Server ODBC Driver Version 03.85.1117 OLEDB: Sybase ACE OLE DB Provider Version 02.70.0032 As a result we want to know the reason (and possible solutions) CommandTimeout property doesn’t work at all and Cancel method doesn’t work in some cases (3 types of database access, Sybase, Microsoft SQL Server). заранее спасибо... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 27.03.2007, 18:22 |
|
||
|
ADO - баг или нет?
|
|||
|---|---|---|---|
|
#18+
А документацию читать кто будет? ADO 2.8 API Reference CommandTimeout PropertyUse the CommandTimeout property on a Connection object or Command object to allow the cancellation of an Execute method call, due to delays from network traffic or heavy server use. If the interval set in the CommandTimeout property elapses before the command completes execution, an error occurs and ADO cancels the command. If you set the property to zero, ADO will wait indefinitely until the execution is complete. Make sure the provider and data source to which you are writing code support the CommandTimeout functionality. The CommandTimeout setting on a Connection object has no effect on the CommandTimeout setting on a Command object on the same Connection; that is, the Command object's CommandTimeout property does not inherit the value of the Connection object's CommandTimeout value. On a Connection object, the CommandTimeout property remains read/write after the Connection is opened. Обрати внимение на выделеную фразу. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 28.03.2007, 01:47 |
|
||
|
ADO - баг или нет?
|
|||
|---|---|---|---|
|
#18+
если б это было только у Sybase, я б поверил, но то же творится с MS SQL Server... по идее ДОЛЖНО работать... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 28.03.2007, 11:11 |
|
||
|
ADO - баг или нет?
|
|||
|---|---|---|---|
|
#18+
Еще раз о результатах: 1. Access with OLE DB: Conclusions: 1. CommandTimeout is ignored for ADODB:Command and ADODB:Connection objects (MS SQL, Sybase) 2. Exception occurs in Execute method (asynchronous execution). It looks rather strange as exception is thrown to another thread as GUI (Application has window) works when exception occurs. (MS SQL Server). 3. Cancel method holds the application until the procedure is not executed completely. When Execute method finishes its execution control is returned to the application (GUI) (Sybase). 2. Access with ODBC: Conclusions: 1. CommandTimeout is ignored for ADODB:Command and ADODB:Connection objects (MS SQL, Sybase) 2. Execute method (asynchronous execution) works correctly (MS SQL и Sybase). Procedure is interrupted. 3. Access with OLEDB provider for ODBC: Conclusions: 1. CommandTimeout is ignored for ADODB:Command and ADODB:Connection objects (MS SQL, Sybase) 2. Execute method (asynchronous execution) works correctly (MS SQL и Sybase). Procedure is interrupted. т.е. ни через ODBC, ни через OLEDB даже с SQL Server CommandTimeout не работает... т.е. Make sure the provider and data source to which you are writing code support the CommandTimeout functionality. получается что даже для SQL Server-а нельзя быть sure? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 28.03.2007, 11:15 |
|
||
|
ADO - баг или нет?
|
|||
|---|---|---|---|
|
#18+
Это их старая бага. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 28.03.2007, 18:21 |
|
||
|
ADO - баг или нет?
|
|||
|---|---|---|---|
|
#18+
rainbow_demonесли б это было только у Sybase, я б поверил, но то же творится с MS SQL Server... по идее ДОЛЖНО работать...Должно, не значит обязано :) Только у некоторых серверов вообще есть такое понятие как таймаут на команду. Поддерживается ли эта фича в данном сервере надо смотреть документацию на данный сервер, на конкретную версию сервера. В общем, я очень не рекомендую с этим возится. Если надо ограничитить время выполнения запроса - выноси синхронный запрос в отдельную нить и жди ее завершения определенное время, либо делай асинхронный запрос и сиди в цикле проверяй завершился запрос или еще нет. Если запрос по достижении таймаута не завершен - обламывай его. В совсем крайнем случае, если запрос не обламывается - рви коннект. Это будет работать одинаково надежно в любой базе. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 28.03.2007, 20:50 |
|
||
|
ADO - баг или нет?
|
|||
|---|---|---|---|
|
#18+
у меня все работает что MSSQL2000/20005/ DB2 8.2 проверь свой MDAC какая версия ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 29.03.2007, 06:41 |
|
||
|
ADO - баг или нет?
|
|||
|---|---|---|---|
|
#18+
Lepsik: MDAC 2.8... Tracer: что за старый баг? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 29.03.2007, 11:09 |
|
||
|
|

start [/forum/topic.php?fid=57&msg=34423835&tid=2029154]: |
0ms |
get settings: |
7ms |
get forum list: |
17ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
162ms |
get topic data: |
12ms |
get forum data: |
3ms |
get page messages: |
58ms |
get tp. blocked users: |
1ms |
| others: | 202ms |
| total: | 468ms |

| 0 / 0 |
