I am calling a stored procedure using ASP.Net page. The stored procedure takes a long time so I have set database command timeout property to 0 which means infinite. I have also set executionTimeout in web.config to 7200 which means 2 hours.
When stored procedure is called from that page, after a long time it throws error:
This page can't be displayed
I have written try catch block and set break point but it doesn't come inside catch.
How do I fix this issue?
EDIT
Here's the code:
try
{
//database is Sybase
ConnectionOpenedHere();
AseCommand command = new AseCommand();
command.Connection = con;
command.CommandType = CommandType.StoredProcedure;
command.CommandTimeout = 0;
//some more code here
command.CommandText = storedProcedure;
command.ExecuteNonQuery(); //The code doesn't go beyond this line and shows error after a long time
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
EDIT
Finally able to catch the exception. Here's the error:
Error: Connection to Sybase server has been lost. All active transactions have been rolled back
Stack Trace: at Sybase.Data.AseClient.AseCommand.CheckResult(Int32 res) at Sybase.Data.AseClient.AseCommand.Execute() at Sybase.Data.AseClient.AseCommand.ExecuteNonQuery() at MyWebsite.Database.MyStoredProcedure(Int32 subtype, string idno)
There is no Inner Exception.
Try below solution in your web.config file. Hope this will works. It will hold execution extended till your Store Procedure runs..
But your Store Procedure must be perfect.
And Add Machine Key also