IAsyncResult.IsComplete在存储过程完成执行之前返回True [英] IAsyncResult.IsComplete is returining True before stored procedure completes execution
问题描述
这是关于ADO.NET 2.0异步执行。
1)在连接字符串中我有异步进程为True
2)我有BeginExecuteNonQuery并传递给IAsyncResult处理程序
3)在BeginExectureNonQuery中我调用一个存储过程,我将打开一个游标并获取每个记录并做一些过程并插入到其他表中。
我将从一个数据库中获取并将数据插入到其他数据库中。由于我有一个共同的用户帐户,我能够做到这一点。
4)从查询分析器我运行的程序工作查找,它花了15分钟并完成了这个过程
现在问题是当我从Windows客户端应用程序运行它时,它运行一分钟然后由于某种原因 IAsyncResult.IsComplete是真实的 ,因为它正在尝试执行EndExectureNonQuery,并且由于存储的部分没有完成它的执行,它等待30秒并给出
超时已过期。在完成操作之前经过了超时期限,或者服务器没有响应....
顺便说一句,它是sqlserver 2000和.Net 2.0。任何建议都非常适合...尽快.... !!!!
如果想要看到代码......它的'
Dim _SRet As 字符串 = ""
Dim _SqlCmd As 新 SqlCommand( < font color ="#a31515"size = 1>" SP_Proc10" ,_ sqlCon)
_SqlCmd.CommandType = CommandType.StoredProcedure
Dim _ErrMsg 如 新 SqlPa rameter( " @ ErrSTAT" ,SqlDbType.VarChar,4000)
_ErrMsg.Direction = ParameterDirection.Output
'将它们添加到参数集合
_SqlCmd.Parameters.Add(_ErrMsg)
_SqlCon.Open()
Dim IA As IAsyncResult = _SqlCmd.BeginExecuteNonQuery()
Dim IC As 整数 = 0
当 ( 不 IA 。已完成)
IC = IC + 1
TextBox1.Text = IC
Thread.Sl eep(100)
结束 虽然
Dim rowCount As Integer = _SqlCmd.EndExecuteNonQuery(IA)
MsgBox(_SqlCmd.Parameters(
" @ ErrSTAT" )。值)
大家好
我遇到类似BeginExecuteNonQuery()的问题。与上面相同,我们打开游标并将一些数据库插入到不同的数据库中,但是在同一台机器上。查看类似的帖子,在执行基于游标的异步查询时,IAsyncResult类必定存在问题。有没有人知道解决方案?
在调用EndExecuteNonQuery()期间我们没有得到超时。这可能是因为我们设置了SqlCmd.CommandTimeout = 0.这将导致命令无限期地等待。结果
This is regarding ADO.NET 2.0 Async execution.
1) In connection string I have async process as True
2) I have BeginExecuteNonQuery and passed to IAsyncResult handler
3) In BeginExectureNonQuery I am calling a stored procedure in that I will open a cursor and fetch each record and do some process and insert into other table.
I will fetch from one database and insert data into some other database. As I have a common user account I am able to do that.
4) From Query analyzer I ran the procedure worked find, It took 15 min and completed the process
Now the problem is when I ran this from windows client application, it runs a minute and then for some reason IAsyncResult.IsComplete is becomming true as that it's trying to execute EndExectureNonQuery and as the stored porcedure did not completed it's execution, it's waiting 30 seconds and giving
Timeout expired. The timeoutperiod elapsed prior to completion of the operation or the server is not responsing....
By the way it's sqlserver 2000 and .Net 2.0. Any suggestions are greatly appriciated...ASAP....!!!!
In case want to see the code ...its'
Dim _SRet As String = "" Dim _SqlCmd As New SqlCommand("SP_Proc10", _sqlCon)
_SqlCmd.CommandType = CommandType.StoredProcedure
Dim _ErrMsg As New SqlParameter("@ErrSTAT", SqlDbType.VarChar, 4000)_ErrMsg.Direction = ParameterDirection.Output
'add them to the parameter collection
_SqlCmd.Parameters.Add(_ErrMsg)
_SqlCon.Open()
Dim IA As IAsyncResult = _SqlCmd.BeginExecuteNonQuery() Dim IC As Integer = 0 While (Not IA.IsCompleted)IC = IC + 1
TextBox1.Text = IC
Thread.Sleep(100)
End While Dim rowCount As Integer = _SqlCmd.EndExecuteNonQuery(IA)MsgBox(_SqlCmd.Parameters(
"@ErrSTAT").Value)Hi all
I am having a similar problem with BeginExecuteNonQuery(). Same as above, we are opening a cursor and performing some database inserts into a different database, but on the same machine. Looking at similar posts, there must be an issue with the IAsyncResult class when executing async queries based on cursors. Does anyone know of a resolution?
We don't get the timeout during the call to EndExecuteNonQuery(). That may be because we have set SqlCmd.CommandTimeout = 0. This will cause the command to wait indefinately.
这篇关于IAsyncResult.IsComplete在存储过程完成执行之前返回True的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!