Connection Timeout exception for a query using ADO.Net
Posted
by dragon
on Stack Overflow
See other posts from Stack Overflow
or by dragon
Published on 2008-09-19T21:08:46Z
Indexed on
2010/04/04
6:33 UTC
Read the original article
Hit count: 331
Update: Looks like the query does not throw any timeout. The connection is timing out.
This is a sample code for executing a query. Sometimes, while executing time consuming queries, it throws a timeout exception.
I cannot use any of these techniques: 1) Increase timeout. 2) Run it asynchronously with a callback. This needs to run in a synchronous manner.
please suggest any other techinques to keep the connection alive while executing a time consuming query?
private static void CreateCommand(string queryString,
string connectionString)
{
using (SqlConnection connection = new SqlConnection(
connectionString))
{
SqlCommand command = new SqlCommand(queryString, connection);
command.Connection.Open();
command.ExecuteNonQuery();
}
}
© Stack Overflow or respective owner