TimeOut on SqlDataAdapter.Fill

D

Dan

I've created a web form which fills a DataGrid with a DataSet generated from
the SqlDataAdapter.Fill method. The adapter's query takes about 30 seconds
to complete when I run it in the SQL Server Query Analyzer, but when I run
it from my web page I kept getting a TimeOut exception. So then, as an
experiment, I changed the way I created the adapter to the following:

SqlConnection conn = new SqlConnection(m_Conn);
SqlCommand sqlCommand = new SqlCommand(m_Query, conn);
sqlCommand.CommandTimeout = 0;
m_Adapter = new SqlDataAdapter(sqlCommand);

However, I'm still getting the TimeOut exception on the adapter.Fill method.
What do I need to do to make this work? The relevant portion of the
exception reads as follows:


System.Data.SqlClient.SqlException: Timeout expired. The timeout period
elapsed prior to completion of the operation or the server is not
responding. at
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior,
RunBehavior runBehavior, Boolean returnStream) at
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at
System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(Comman
dBehavior behavior) at
System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet
dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand
command, CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top