asp.net.ph

SqlCommand.CommandTimeout Property

System.Data.SqlClient Namespace   SqlCommand Class


Sets or retrieves the wait time before terminating the attempt to execute a command and generating an error.

Syntax


Script SqlCommand.CommandTimeout [ = intTimeout ]

Property Value


intTimeout The time ( in seconds ) to wait for the command to execute.

The property is read/write with a default value of 30.

Implements

IDbCommand.CommandTimeout

Exceptions


Exception Type Condition
ArgumentException The property value assigned is less than 0.

Remarks

A value of 0 indicates no limit, and should be avoided in a CommandTimeout because an attempt to execute a command will wait indefinitely.

Example

The following example illustrates how the CommandTimeout property can be set.

void setSqlCommand ( ) {
   SqlCommand myCommand = new SqlCommand ( );
   myCommand.CommandText = "SELECT * FROM Categories ORDER BY CategoryID";
   myCommand.CommandTimeout = 15;
}
  C# VB

See Also

SqlCommand Members   CommandText   Connection   CommandType Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph