This error occurs when a database query or stored procedure’s execution time beyond a pre-set timeout period. When you are trying to retrieve a huge amount of data, more execution time may be required.
There are 2 main Timeout properties in .NET:
1. Connection Timeout – It could be solved by setting ConnetionTimeout property in your connection string. For example:
<add key="DBConnection" value="server=localhost;uid=sa;pwd=;database=dbName;Connect Timeout=200; pooling='true'; Max Pool Size=200"/>
2. Timeout for Data Access (Command Object) – You can set a CommandTimeout property to your Command object. For example:
public void CreateMySqlCommand() {
SqlCommand myCommand = new SqlCommand();
myCommand.CommandTimeout = 15;
myCommand.CommandType = CommandType.Text; }
or if you are using data adapter instead of SqlCommand, you can get the Timeout property via: DataAdapter.SelectCommand.CommandTimeout
0 comments:
Post a Comment