SqlCommand.ExecuteScalar Cancel

谁说我不能喝 提交于 2019-12-25 02:33:16

问题


Is there any way to run SqlCommand.ExecuteScalar() asynchronously and then cancel it (on the server side as well) whilst it's being executed?


回答1:


.NET Framework 4.5 has a ExecuteScalarAsync() method.
See here: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.executescalarasync(v=vs.110).aspx

ExecuteScalarAsync() also has an overload with a CancellationToken parameter that can be used to abandon the operation before the command timeout elapses.



来源:https://stackoverflow.com/questions/10244392/sqlcommand-executescalar-cancel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!