I am working on a C# application that calls stored procedures from a SQL server. Depending on the search parameters the user inputs, the stored procedure can take a while and return many records.
I want to implement a cancel button so the user can cancel the execution of the stored procedure when it takes to long. I run the call to the stored procedure in a new thread so the GUI doesn't get affected when the stored procedure takes a while. I read about aborting a thread but found many rejecting opinions about using abort.
Possible solutions i think of:
To disable a stored procedure permanently, you can: Drop the procedure using the DROP PROCEDURE statement. Use an ALTER PROCEDURE statement. Rename or delete the z/OS load module.
Stored procedures are faster as compared to LINQ query since they have a predictable execution plan and can take the full advantage of SQL features. Hence, when a stored procedure is being executed next time, the database used the cached execution plan to execute that stored procedure.
Language-Integrated Query (LINQ) makes it easy to access database information, including database objects such as stored procedures. The following example shows how to create an application that calls a stored procedure in a SQL Server database.
You might not want to use Linq here. Try this:
Stop SQL query execution from .net Code
Basically use SqlCommand.Cancel()
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.cancel.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With