I have a Thread running sql query
how can do i force stop the thread when i dont want to use it anymore.
I have a form that loads 100k from sql server
i retrieve first the 2k then the thread runs to retrieve the other data
i want to kill the thread before it finish when i close the form.
Thread.Abort() is useless.. any help?
Thank you for the reply..The issue is when the sql query still not finish and i want to abort the thread that running the sql query. The sql query still run i cannot close the sql connection.
here is the scenario. i have a datagrid view when i click the add item buttom it loads a form. the form retrieves 2000 data first and store it in a temporary table with a different connection and the last data are retrieve by a differnt connection and stores and a different temp table then i drop the first temp table.
i design my form like this because its to slow to retrieve all data, I want the user not to wait for a long time but can select and view from the first 2000 while the program is still retriving the other data
You could give SqlCommand.Cancel() a try, although I hear it isn't very reliable. Another option is to close the connection. Closing the connection should immediately raise an exception (which you'll have to deal with).