Run SQL in a .NET Thread

  • I have a .Net Windows Forms app in C# in which I execute a SQL statement using SQLDataAdapter.  I want the user to be able to kill the SQL statement if it seems to take to long.  My thought is to execute the SQL in its own thread.  Then when the user clicks a Cancel button it just stops the Thread. 

    Is this the best way to do this?  Will it work?  Is is inefficient?

    Thanks,

    Mark Mokris

  • I've done some thing similar a while back.  I will say it is inefficient ..the main problem I had was determining whether the thread had completed.  Basically find the spid and use kill to kill it.  Encapsulate the kill command in a sp ..call the sp using ADO.Net.

     

    HTH


    Mathew J Kulangara
    sqladventures.blogspot.com

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply