如何从C#停止Sql Server执行过程 [英] How to Stop Sql Server Execution Process from C#

查看:154
本文介绍了如何从C#停止Sql Server执行过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在Windows应用程序中使用C#设计查询分析器。用户可以从给定字段设计查询然后单击一个按钮,执行结果显示后查询进入sql server datagridview.But我的问题是,如果用户单击查询执行同时需要很长时间的按钮,如何使用另一个按钮事件停止执行过程。



示例:Button1 - >提交

Button2 - >停止



提交 - >对于查询执行过程。

停止 - >停止执行流程。





预付款,

T.Saravanan :confused:

Hi,
I design a query analyzer in windows application using C#.User can design a query from a given fields and then click a button, the query goes to sql server after execution result show in datagridview.But my question is if user click a button that query execution take a long time at the same time,how to stop that execution process using another button event.

Example: Button1--> Submit
Button2--> Stop

Submit--> For Query Execution Process.
Stop --> Stop that Execution Process.


Advance Thanks,
T.Saravanan :confused:

推荐答案

使用索引在C#或任何语言代码中执行sql查询,比如过滤查询为posible,因为它将获取所需的数据,它会很容易使执行停止,它会使它更快,在代码中使用简短的过滤器使其变得简单并使您的SQL执行更快。 :)

Prasad Vagal
Use indexes to execute your sql query in C# or any language code, say filter query as posible, as it will fetch as much data it need, it will be easy to make execution stop, it will make it faster, in short use filters in your code to make it simple and to make work your sql execution faster. :)
Prasad Vagal


您好b $ b

尝试使用 SQLCommand.Cancel 来停止执行长时间运行的查询
Hi
Try using the SQLCommand.Cancel to stop executing the long running query


这篇关于如何从C#停止Sql Server执行过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆