This is not a connection timeout as a connection to the database is made fine. The problem is that the stored procedure that I'm calling takes longer than, say, 30 seconds and causes a timeout.
The code of the function looks something like this:
SqlDatabase db = new SqlDatabase(connectionManager.SqlConnection.ConnectionString);
return db.ExecuteScalar(Enum.GetName(typeof(StoredProcs), storedProc), parameterValues);
The ExecuteScalar call is timing out. How can I extend the timeout period of this function?
For quick stored procedures, it works fine. But, one of the functions takes a while and the call fails. I can't seem to find any way to extend the timeout period when the ExecuteScalar function is called this way.
If you are using the EnterpriseLibrary (and it looks like you are) try this:
Edited to handle the paramValues array directly based on the comments. I also included your ConnectionString value:
Try this one
Timeout can occur due to a Microsoft issue. Seems to still occur on my Windows 8 system.
http://support.microsoft.com/kb/2605597?wa=wsignin1.0
I think this might be a better way to do this (as of Enterprise Library 6.0):
Mladen is right but if you have to do this you probably have a bigger problem with the proc itself. Under load it might take much longer than your new timeout. Might be worth spending some quality time with the proc to optimize.
you do this by setting the SqlCommand.CommandTimeout property