Abort SQL Query using C#

How to abort SQL Query programatically using C#

Page 1 of 1

2 Replies - 3277 Views - Last Post: 06 July 2010 - 09:11 PM Rate Topic: -----

#1 ALJAY9432  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-July 10

Abort SQL Query using C#

Posted 06 July 2010 - 01:16 PM

I am looking for a method to prematurely abort a SQL Query that may or may not be running for a long time. I work in a data warehouse environment and am developing software for which this is a requirement. Does anybody know the method to stop a query whilst it is running using C# or VB.NET ?
This is a desktop / windows forms application.

Thanks all!
Is This A Good Question/Topic? 0
  • +

Replies To: Abort SQL Query using C#

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6052
  • View blog
  • Posts: 23,487
  • Joined: 23-August 08

Re: Abort SQL Query using C#

Posted 06 July 2010 - 03:44 PM

Moved to C#
Was This Post Helpful? 0
  • +
  • -

#3 Momerath  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1010
  • View blog
  • Posts: 2,444
  • Joined: 04-October 09

Re: Abort SQL Query using C#

Posted 06 July 2010 - 09:11 PM

If you are worried that a SQL statement may take a long time, use the async calls:
BeginExecuteNonQuery(), BeginExecuteReader(), etc.

Then if you determine that it has taken to long, you can use the End... calls to stop them.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1