I have a winforms project that loads a DataView grid async so that the user can hit cancel (and the form does not get "not responding"). I am getting timeouts sometimes in the While dr.Read ... End While.
I can override the timeout default, but isn't there any other way? It would be nice if the timeout could be trapped and let me try again at the same point in the progression of the reader.
My db is SQLServer 2000 sp4.
Here is the code to create the reader. Note that I am setting the option to close the connection when reader is done.
'SMCNITT 05/23/2008 tg.74 timeout error on fill of grid
'-timeout override was passed but not used!
If Not CommandTimeout Is Nothing Then
.CommandTimeout = (CInt(CommandTimeout)) 'caller can override command timeout
.CommandText = "spMsgValGridPreviewBatchRS"
.Connection = cnn
.CommandType = CommandType.StoredProcedure
.Parameters.Item("@Recordcount").Direction = ParameterDirection.Output
mblnAsyncProcessInProgress = True
result = .BeginExecuteReader(CommandBehavior.CloseConnection)
While Not result.IsCompleted
'polling for cancel
If mblnCancelModalProcess Then
'create and return the reader
dr = cmd.EndExecuteReader(result)
mblnAsyncProcessInProgress = False
Free Guide: Managing storage for virtual environments
Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!
No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.
Your password has been sent to:email@example.com
To follow this tag...
Thanks! We'll email you when relevant content is added and updated.
Share this item with your network: