.NET SQLClient Data Provider: Timeout expired

Posted on 2013-08-27
Medium Priority
Last Modified: 2013-08-27
.NET SQLClient Data Provider: Timeout expired when running a ODBC connection from a Win7 to Win2008R2 SQL2008R2 DB.  Connection establishes on basic ODBC but continually times out.

What I have tried:
1) Adding "Connection Timeout=0" and "context connection=true" in ODBC string
2) Setting SQL connection to 0
3) Trying different ODBC connection types

sp and query runs fine on SQL with no issues, it just takes about 5 minutes to complete interpolation.

Question by:nwentland
  • 3
  • 2
LVL 19

Accepted Solution

Melih SARICA earned 2000 total points
ID: 39441712
connection timeout is not about query execution.  its about query connection timeout..

If ur query returns data on SQL in 5 mins.. u ave to set the commandtimeout property of SQLcommand

check link


Author Comment

ID: 39441730
I saw this link and it mentions "context connection=true" is set in the string this will null the code.
LVL 19

Expert Comment

by:Melih SARICA
ID: 39441782
did u try setting thhe timeout value of ur SQLCommand that u ll execute ?
Context connetion or Connection Timeout is totally different. they are all about connection. UR problem is about query execution.

Author Comment

ID: 39443555
Sorry for being ignorant, but will this require a recompile of .NET?

using System;
using System.Data.SqlClient;
public class A {
   public static void Main() {
      string connectionString = "";
      using (SqlConnection connection = new SqlConnection(connectionString)) {
         SqlCommand command = new SqlCommand(queryString, connection);
         command.CommandTimeout = 3600;
         try {
         catch (SqlException e) {
            Console.WriteLine("Got expected SqlException due to command timeout ");
LVL 19

Expert Comment

by:Melih SARICA
ID: 39443660
recompile of what ? Ur code ? probably yes u ll ave to recompile..

Featured Post

A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question