Timeout on "DataAdapter.Fill"

G

Guest

Hi all

I have a timout problem when I call "DataAdapter.Fill".
When I debug, I see that all timeout settings are correct,
ConnectionTimeout is 0 and also CommandTimeout is 0.

But when I call the fill method I get:
"Timeout expired. The timeout period elapsed prior to completion of the
operation or the server is not responding."} System.Exception
{System.Data.SqlClient.SqlException}

Here is what I do:
Conn.ConnectionString = "Data Source=ServerXY;Initial Catalog=master;Connect
Timeout=0;Integrated Security=SSPI;"
Command.CommandTimeout = 0
System.Data.SqlClient.SqlDataAdapter local_DataAdapter = new
System.Data.SqlClient.SqlDataAdapter(Query, Conn);
System.Data.DataSet local_DataSet = new System.Data.DataSet();
local_DataAdapter.Fill(local_DataSet, DataSetTableName);

Thanks for any comments !!

Regards
Frank
 
A

Alberto Poblacion

Frank Uray said:
I have a timout problem when I call "DataAdapter.Fill".
When I debug, I see that all timeout settings are correct,
ConnectionTimeout is 0 and also CommandTimeout is 0.

But when I call the fill method I get:
"Timeout expired. The timeout period elapsed prior to completion of the
operation or the server is not responding."}

One case where this happens is if you are opening connections but not
closing them. Every time this happens, a connection is consumed, and when
you reach the configured maximum (typically 100), the next time that you
attempt to open a connection the system waits for one of the open
connections to be freed. Since this doesn't hapen, you finally get a timeout
error. The problem is that the faulty code is somewhere else (in the part of
the program that is opening and not closing the connections), and not in the
piece of code that displays the error, so it's difficult to debug.
 
G

Guest

I have found the problem:
On The DataAdapter there is also a CommandTimeout within
SelectCommand. This has to be set also ...

System.Data.SqlClient.SqlDataAdapter local_DataAdapter = new
System.Data.SqlClient.SqlDataAdapter(Query, return_SQLNATIVEConnection);
System.Data.DataSet local_DataSet = new System.Data.DataSet();
local_DataAdapter.SelectCommand.CommandTimeout = 0;
local_DataAdapter.Fill(local_DataSet, DataSetTableName);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top