Possible Duplicate:
How to catch SQLServer timeout exceptions
I have the following code:
using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MainDll"].ToString()))
{
connection.Open();
using (SqlCommand command = new SqlCommand(sql.ToString(), connection))
{
command.CommandType = CommandType.Text;
command.CommandTimeout = 300;
returnCode = (string)command.ExecuteScalar();
//Dispose();
}
}
How do I know when the timeout has been reached? I want to grab it and do something with the SQL after the timeout.