Cancel a myDataAdapter.fill(myDataSet) ?

  • Thread starter Thread starter Sylvain Ross
  • Start date Start date
S

Sylvain Ross

Hi,
I've looking around for canceling the filling of a dataset with the :
da.fill(ds,"blah") with da a SqlDataAdapter and ds a dataset.

I tried to do from a different thread : da.SelectCommand.Cancel, but it
doesnt work.

I also tried to run the da.fill(ds,"blah") from a different thread and
then to kill this thread from my main thread, but it doesnt work (even
if I do a myFillingThread.Abort(), it keep doing the filling. When the
filling is done, then the thread is killed, but not while doing the
filling).

If anyone know how to do this, should be great.

If anyone can confirm me that this is not possible, should be even great
(not as much great as the solution though ;))

I'm using SQL Server 2000.

I had the idea to try to get the pid of the SELECT command filling the
dataset and then to kill it through SQL Server sp_kill command, but I
don't have an easy way to get the pid of the select command of my
dataAdapter when runing it. Anyway this is a bit too "hacky" for me.
 
Hi,

Asynch mode, which could be cancelled, was available in ADO, but as I know
this mode is not in ADO.NET yet and should be available in a next versions
of it. I do not think you could do it now
 
using adapter.SelectCommand.Cancel() should work most of the time, although
there are situations where it either doesn't work at all (e.g. the cancel
request arrives to the server in a phase of the processing that cannot be
aborted) or it takes a long time (e.g. until the server enters a state that
can be aborted). This is the nicer way of aborting an ongoing operation.

If this really doesn't work, you can still open the connection manually
(instead of letting the adapter opening it for you) and execute a "SELECT
@@SPID" to find out the spid; then you can kill the spid from another
connection. I agree with you that this is kind of brute force.

--
Pablo Castro
Program Manager - ADO.NET Team
Microsoft Corp.

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top