User36583972 posted
Hi Faraz A. Qureshi,
From your description, I think causes the timeout problem are so many, there are two possibilities:
• Estimated time is not accurate.
• SQL statement relates to memory-intensive queries (such as sorting and hashing operations), not enough memory, we need to wait in line resources as a result.
you can try the following suggestion to optimize your program.
• Query optimization (Query with order by can improving efficiency)
• Using appropriate indexes
You should avoid full table scan. The first consideration should be given based on where and order by columns involved in the index.
• Increase query timeout
SqlCommand com = new SqlCommand();
com.CommandTimeout = 60; //s
• Increase the connection time
string connectionString = "Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=SSPI;Connection Timeout=300";
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
Console.WriteLine("State: {0}", connection.State);
Console.WriteLine("ConnectionTimeout: {0}",connection.ConnectionTimeout);
}
• Increase memory
Best Regards,
Yohann Lu