Link to home
Start Free TrialLog in
Avatar of Christian Hoffmann
Christian Hoffmann

asked on

SqlDataAdapter.Fill - Timeout expired. The timeout period elapsed or the server is not responding

My C# application is showing ominous behaviour.

The application is working perfectly fine for a specific Installation. But it's giving me this exception in another..
- SqlDataAdapter.Fill - Timeout expired.  The timeout period elapsed Prior to executing the query or the Server is not responding.

I've been searching all day for a solution and cant find anything helpful.

The c# Code is

            DataTable dt = new DataTable(tableName);
            try
            {
                using (SqlDataAdapter da = new SqlDataAdapter(SqlQuery, conn))
                {
                    Console.Write(SqlQuery);
                    da.Fill(dt);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Foo String there is nothing good Happening {0}", ex.ToString()));
            }

Open in new window


The SQL is : SELECT * FROM FooTable WHERE ColumnA=0 and ColumnB='15'

Every Google post I've been looking at is about "increase your command timeout". Which makes me almost give up hope.

The same SQL in SSMS Returns only 1 row and I've seriously no idea what is going on.

I've attached a Debugger to the process and can definitely say the code is reaching the Console.Write as a breakpoint.
The exception is thrown at the fill method line.

I'm highly thankful for any responses.
Avatar of WestcountryBusiness
WestcountryBusiness

Check your connection string.  Is it possible your adapter isn't able to communicate with the server?
post some more code that shows connection string, how do you open connection etc...
Avatar of Christian Hoffmann

ASKER

Thanks for the Response.

The connection string is : Data Source=sql01\2014;Initial Catalog=DBNAME;User ID=sa;Password=FooPass

and the Connection is opened with this Code :

conn.ConnectionString = ConnectionString;
conn.Open();

Open in new window

The Adapter is working fine with 3 different queries in the Code beforehand or else the Breakpoint wouldn't be reached.
I've just done a database dump to our development environment and successfully run the whole application there with no Errors.

I think it may be related to .NET Features or the SQL Preferences.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.