PC Review


Reply
Thread Tools Rate Thread

DataAdapter.Fill(Dataset) shows timeout error.

 
 
Manohar
Guest
Posts: n/a
 
      21st Aug 2007
I am executing a stored procedure and returning a resultset. The
stored procedure takes approx 40 secs to execute. I have set the
connection and command timeout to 10000, but I am still getting the
error, "Timeout expired. The timeout period elapsed prior to
completion of the operation or the server is not responding."

Here is the code for executing the stored procedure.
private DataSet ExeCmdWithDataSet(string SQLText, string strdbconnect)
{
SqlConnection cn = new SqlConnection();
cn.ConnectionString = strdbconnect;
cn.Open();

DataSet ds = new DataSet();
SqlCommand cmd = new SqlCommand();
cmd.CommandTimeout = 10000;
cmd.CommandType = CommandType.Text;
cmd.CommandText = SQLText;
cmd.Connection = cn;

cmd.Prepare();

SqlDataAdapter da = new SqlDataAdapter(SQLText, cn);
da.Fill(ds);
cn.Close();

return ds;
}

Please help.

Thanks,

 
Reply With Quote
 
 
 
 
=?Utf-8?B?QnJhdWxpbyBEaWV6?=
Guest
Posts: n/a
 
      22nd Aug 2007
Mmm...

I think it could be a good idea to check first if the problems is related
with the DataSet or if it's the Stored procedure or if it's too much data.

Could try to run the same query using a SqlDataReader and a loop and check
if using that retrieves data ? (from there we can further research and check
if it's because of the dataset or ...)

HTH
Braulio

/// ------------------------------
/// Braulio Diez
///
/// http://www.tipsdotnet.com
/// ------------------------------




"Manohar" wrote:

> I am executing a stored procedure and returning a resultset. The
> stored procedure takes approx 40 secs to execute. I have set the
> connection and command timeout to 10000, but I am still getting the
> error, "Timeout expired. The timeout period elapsed prior to
> completion of the operation or the server is not responding."
>
> Here is the code for executing the stored procedure.
> private DataSet ExeCmdWithDataSet(string SQLText, string strdbconnect)
> {
> SqlConnection cn = new SqlConnection();
> cn.ConnectionString = strdbconnect;
> cn.Open();
>
> DataSet ds = new DataSet();
> SqlCommand cmd = new SqlCommand();
> cmd.CommandTimeout = 10000;
> cmd.CommandType = CommandType.Text;
> cmd.CommandText = SQLText;
> cmd.Connection = cn;
>
> cmd.Prepare();
>
> SqlDataAdapter da = new SqlDataAdapter(SQLText, cn);
> da.Fill(ds);
> cn.Close();
>
> return ds;
> }
>
> Please help.
>
> Thanks,
>
>

 
Reply With Quote
 
=?Utf-8?B?UGVwYQ==?=
Guest
Posts: n/a
 
      4th Sep 2007
Hi,

you create SqlCommand and then SqlDataAdapter, but they have got no
asociation except query string. So Timeout is set to cmd, but not to command
da creates when you pass him the query string. You have to create
SqlDataAdapter like this:

SqlDataAdapter da = new SqlDataAdapter(cmd);

Now da uses cmd and it should work.

HTH
Pepa

"Manohar" wrote:

> I am executing a stored procedure and returning a resultset. The
> stored procedure takes approx 40 secs to execute. I have set the
> connection and command timeout to 10000, but I am still getting the
> error, "Timeout expired. The timeout period elapsed prior to
> completion of the operation or the server is not responding."
>
> Here is the code for executing the stored procedure.
> private DataSet ExeCmdWithDataSet(string SQLText, string strdbconnect)
> {
> SqlConnection cn = new SqlConnection();
> cn.ConnectionString = strdbconnect;
> cn.Open();
>
> DataSet ds = new DataSet();
> SqlCommand cmd = new SqlCommand();
> cmd.CommandTimeout = 10000;
> cmd.CommandType = CommandType.Text;
> cmd.CommandText = SQLText;
> cmd.Connection = cn;
>
> cmd.Prepare();
>
> SqlDataAdapter da = new SqlDataAdapter(SQLText, cn);
> da.Fill(ds);
> cn.Close();
>
> return ds;
> }
>
> Please help.
>
> Thanks,
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with DataAdapter.Fill(Dataset) Stanav Microsoft VB .NET 3 14th Nov 2005 03:17 PM
DataAdapter.Fill(dataset): Null exception Stanav Microsoft ASP .NET 2 14th Nov 2005 01:50 PM
Question on DataAdapter.Fill(DataSet) method =?Utf-8?B?bm9ubm8=?= Microsoft C# .NET 2 22nd Jul 2005 09:33 PM
Timeout on DataAdapter.Fill Polly Microsoft C# .NET 0 21st Apr 2005 10:51 AM
Timeout when calling fill method for dataadapter object William C Microsoft ADO .NET 2 25th Nov 2003 12:46 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:29 AM.