There are two main Timeout property in ADO.NET.
1. Connection Timeout for Connection
2. Timeout for Data Access( Command Object or DataAdapter)
Setting Connection Timeout property for SQLConnnection object ?
You can't set timeout property in connection object because its a READ ONLY property.
SqlConnection conn = new SqlConnection("server=Server;uid=sa;pwd=123456;database=myDB;Connection Timeout=120");
Setting the timeout property in DataAdapter or CommandObject.
SqlDataAdapter sqlAdapter = new SqlDataAdapter();
sqlAdapter.SelectCommand = new SqlCommand(sqlQuery, conn);
sqlAdapter.SelectCommand.CommandTimeout = 0;
Setting the timeout value to 0 will makes adapter or command to wait for indefinite time before terminating the attempt to execute a command and generating an error. The default timeout value for connection object is 15 seconds.
hope this might help you to solve the problem.
0 comments:
Post a Comment