Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Stopping command execution

Author  Topic 

hadoft
Starting Member

20 Posts

Posted - 2003-10-20 : 14:23:35
hi
this question is about using ADODB.Command Object in Visual Basic


how can i stop the execution of a ADODB.Command running a long update statment

i want to give the user the ability to cut command execution by clicking a cancel button.

nr
SQLTeam MVY

12543 Posts

Posted - 2003-10-20 : 14:25:46
You can create a new connection and issue a kill command - this will cause the transaction to rollback.
You can terminate the connection but this will probably cause the update to roll back when it finishes.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-10-20 : 14:31:48
Won't s/he have to know the spid?



Brett

8-)
Go to Top of Page

hadoft
Starting Member

20 Posts

Posted - 2003-10-20 : 14:43:30
quote:
Originally posted by nr

You can create a new connection and issue a kill command - this will cause the transaction to rollback.
You can terminate the connection but this will probably cause the update to roll back when it finishes.



thanks for the quick replay

but the problem is when I execute the command the program stop execution until the command is finished and even the user can't click the canel button

how can i make the command execution asynchronous ??

Go to Top of Page

Stoad
Freaky Yak Linguist

1983 Posts

Posted - 2003-10-20 : 15:03:39
Do you mean that something like below does not work
or you are totally unfamiliar with that?

cmd.Execute , , adAsyncExecute

Private Sub Button1_Click()
cmd.Cancel
End Sub
Go to Top of Page

hadoft
Starting Member

20 Posts

Posted - 2003-10-20 : 15:20:00
quote:
Originally posted by Stoad

Do you mean that something like below does not work
or you are totally unfamiliar with that?

cmd.Execute , , adAsyncExecute

Private Sub Button1_Click()
cmd.Cancel
End Sub




oh yes I will try it
thanks.
Go to Top of Page

Stoad
Freaky Yak Linguist

1983 Posts

Posted - 2003-10-21 : 04:33:07
Note:
if you just want to free users hands then cmd.Execute , , adAsyncExecute
will be enough. But if you really want to rollback an updating then you should
break (cn.Close) the connection in which the command was issued.
Go to Top of Page
   

- Advertisement -