Re: ADO.NET - Exception "Operation cancelled by user" -

From: dubian (collatz_at_bigtexansoftware.com)
Date: 02/14/05


Date: 14 Feb 2005 07:07:27 -0800

I apologize, I was feeling rushed when I initially posted and obviously
did a poor job with the details.

I created a C# com control to use ADO.NET 1.1 with the SqlClient as the
DB connectivity tool.

When I call 'command.Cancel()', on occasion I get the above
exception and the connection closes. I get an 'attention' when I
monitor with the SQL profile but cannot find the cause or details of
the attention entry.

If I remove the call to cancel, (which is being called before every new
querry), the exception is never seen.

Code sample.

EstablishNewConnection and command associated with connection.

For each new command against server:

Command.Cancel()
anyOpenReaderOnConnection.Close()
Command.CommandText = "sql command"
Command.CommandTimeout() = value
Command.ExecuteReader()

Work with Reader.....

It is when ExecuteReader is called, that the exception is thrown on
occasion. I feel there is some 'racecondition' somewhere getting
mangled by repeatedly calling cancel and that sometimes the cancel is
actually forwarded to the server after ExecuteReader is called. Or
something like that.

Thanks.



Relevant Pages

  • Re: Urgent...Please Help...
    ... Although you're using a new connection (which should be working all else ... Command objects use readers to do a lot of their work so it's possible ... > I keep getting this irritating exception on and on. ... > OdbcCommand myCommand = new OdbcCommand; ...
    (microsoft.public.dotnet.general)
  • Re: Databind Error???
    ... wrapper object looking just like the Microsoft command object and even named ... I'm not opening a connection, ... connection string to the command object and even disposing it and setting it ... An unhandled exception occurred during the execution of the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: return inside of using block
    ... if an exception is thrown during the ... connection are already cleaned up prior to the exception so no worries ... not keeping the command or connection open any longer in either one. ... called when Dispose is called on the connection. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Hard killing a thread thats got resources open (SqlDataAdapter, SqlConnection)
    ... I don't think aborting a thread like this is a good idea (I've been through ... > issue a Cancel() on the Command object. ... so I keep reusing the same connection. ...
    (microsoft.public.dotnet.languages.csharp)
  • Hard killing a thread thats got resources open (SqlDataAdapter, SqlConnection)
    ... issue a Cancel() on the Command object. ... value to check if it actually was successful. ... so I keep reusing the same connection. ...
    (microsoft.public.dotnet.languages.csharp)