General information
Category:
The Mere Mortals .NET Framework
Title:
How do you set the Command Timeout
I have a very large and complex view in my SQL Server. When I try retrieve the rows from this view in my business object with Me.GetDataSet("Select * From myview") I get the error message "Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding."
I traced the code and found that the command object is created in mmDataAccessSql.CreateCommand() of mmData.cs, which is declared like this:
public override IDbCommand CreateCommand(string cmdText, IDbConnection connection)
The command is created with a Command Timeout of 30 seconds. I need about 45 seconds to run my command. I tried increasing the Connection Timeout by adding ;Connection Timeout=60 to the connection string definition in app.config. That didn't help.
I thought about overriding CreateCommand() but the function is not declared virtual and I think I would have to override in several places.
Is there any easy way to increase the Command Timeout from 30 seconds? It seems to me that there should be a Timeout parameter on GetDataSet() which would be passed on to mmDataAccessSql.FillDataSet() where it could be applied to the SqlCommand object.
I'm sure this has been discussed before. Could some kind person please respond with the messageid? Or what do you suggest? Seems like this should be in the help file.
Thanks,
Max...
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only