473,569 Members | 2,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SqlClient.SqlEx ception: Timeout expired.

I'm having an issue with returning a large amount of data into a dataset.
When the query returns thousands of lines of data (in Query Analyzer it can
take 2 minutes) I receive the following error:
Message: System.Web.Serv ices.Protocols. SoapException: Server was unable to
process request. ---> System.Data.Sql Client.SqlExcep tion: Timeout expired.
The timeout period elapsed prior to completion of the operation or the server
is not responding.

My assumption is that I need to raise the command timeout to correct this.
I cannot find a way while using SqlHelper.Execu teDataSet to include a change
to the command timeout. Here is an example of my webservice:
[WebMethod]
public System.Data.Dat aSet QuerySpecificTr ansaction(int transactionID)
{
SqlConnection conn = new SqlConnection() ;
DataSet ds = new DataSet();
SqlParameter[] parms = new SqlParameter[1];

try
{
conn.Connection String =
System.Configur ation.Configura tionSettings.Ap pSettings["ConnectionStri ng"];
parms[0] = new SqlParameter("@ transactionID", SqlDbType.Int);
parms[0].Value = transactionID;
ds = SqlHelper.Execu teDataset(conn, CommandType.Sto redProcedure,
"QuerySpecificT ransaction", parms);
}
catch(Exception exc)
{
throw exc;
}
finally
{
if (conn.State != ConnectionState .Closed)
{
conn.Close();
}
}
return ds;
}
Nov 19 '05 #1
3 16031
you are correct, you need set the Timeout property of the sqlcommand object.
you will proably have to add code to your sqlhelper object to support this.

-- bruce (sqlwork.com)
"Matt" <Ma**@discussio ns.microsoft.co m> wrote in message
news:3F******** *************** ***********@mic rosoft.com...
I'm having an issue with returning a large amount of data into a dataset.
When the query returns thousands of lines of data (in Query Analyzer it
can
take 2 minutes) I receive the following error:
Message: System.Web.Serv ices.Protocols. SoapException: Server was unable to
process request. ---> System.Data.Sql Client.SqlExcep tion: Timeout expired.
The timeout period elapsed prior to completion of the operation or the
server
is not responding.

My assumption is that I need to raise the command timeout to correct this.
I cannot find a way while using SqlHelper.Execu teDataSet to include a
change
to the command timeout. Here is an example of my webservice:
[WebMethod]
public System.Data.Dat aSet QuerySpecificTr ansaction(int transactionID)
{
SqlConnection conn = new SqlConnection() ;
DataSet ds = new DataSet();
SqlParameter[] parms = new SqlParameter[1];

try
{
conn.Connection String =
System.Configur ation.Configura tionSettings.Ap pSettings["ConnectionStri ng"];
parms[0] = new SqlParameter("@ transactionID", SqlDbType.Int);
parms[0].Value = transactionID;
ds = SqlHelper.Execu teDataset(conn, CommandType.Sto redProcedure,
"QuerySpecificT ransaction", parms);
}
catch(Exception exc)
{
throw exc;
}
finally
{
if (conn.State != ConnectionState .Closed)
{
conn.Close();
}
}
return ds;
}

Nov 19 '05 #2
Thanks, Bruce! I've been digging through the SqlHelper object, but can't
find how to accomplish this. Do you happen to know a good source?

Matt

"Bruce Barker" wrote:
you are correct, you need set the Timeout property of the sqlcommand object.
you will proably have to add code to your sqlhelper object to support this.

-- bruce (sqlwork.com)
"Matt" <Ma**@discussio ns.microsoft.co m> wrote in message
news:3F******** *************** ***********@mic rosoft.com...
I'm having an issue with returning a large amount of data into a dataset.
When the query returns thousands of lines of data (in Query Analyzer it
can
take 2 minutes) I receive the following error:
Message: System.Web.Serv ices.Protocols. SoapException: Server was unable to
process request. ---> System.Data.Sql Client.SqlExcep tion: Timeout expired.
The timeout period elapsed prior to completion of the operation or the
server
is not responding.

My assumption is that I need to raise the command timeout to correct this.
I cannot find a way while using SqlHelper.Execu teDataSet to include a
change
to the command timeout. Here is an example of my webservice:
[WebMethod]
public System.Data.Dat aSet QuerySpecificTr ansaction(int transactionID)
{
SqlConnection conn = new SqlConnection() ;
DataSet ds = new DataSet();
SqlParameter[] parms = new SqlParameter[1];

try
{
conn.Connection String =
System.Configur ation.Configura tionSettings.Ap pSettings["ConnectionStri ng"];
parms[0] = new SqlParameter("@ transactionID", SqlDbType.Int);
parms[0].Value = transactionID;
ds = SqlHelper.Execu teDataset(conn, CommandType.Sto redProcedure,
"QuerySpecificT ransaction", parms);
}
catch(Exception exc)
{
throw exc;
}
finally
{
if (conn.State != ConnectionState .Closed)
{
conn.Close();
}
}
return ds;
}


Nov 19 '05 #3
Here's the fix in case anyone else has this issue.
*************** *************** *************** ***********

[WebMethod]
public System.Data.Dat aSet QuerySpecificTr ansaction(int transactionID)
{
SqlConnection conn = new SqlConnection() ;
SqlParameter[] parms = new SqlParameter[1];

try
{
conn.Connection String =
System.Configur ation.Configura tionSettings.Ap pSettings["ConnectionStri ng"];
parms[0] = new SqlParameter("@ transactionID", SqlDbType.Int);
parms[0].Value = transactionID;

SqlCommand com = new SqlCommand();
bool mustCloseConnec tion = false;

PrepareCommand( com, conn, null, CommandType.Sto redProcedure,
"QuerySpecificT ransaction", parms, out mustCloseConnec tion);
using(SqlDataAd apter da = new SqlDataAdapter( com))
{
DataSet ds = new DataSet();
da.Fill(ds);
com.Parameters. Clear();
if(mustCloseCon nection)
conn.Close();
return ds;
}
}
catch(Exception exc)
{
throw exc;
}
finally
{
if (conn.State != ConnectionState .Closed)
{
conn.Close();
}
}
}

private static void PrepareCommand( SqlCommand cmd, SqlConnection conn,
SqlTransaction trans, CommandType cmdType, string cmdText, SqlParameter[]
cmdParms, out bool mustCloseConnec tion)
{
if (conn.State != ConnectionState .Open)
{
mustCloseConnec tion = true;
conn.Open();
}
else
{
mustCloseConnec tion = false;
}

cmd.Connection = conn;
cmd.CommandText = cmdText;

if (trans != null)
cmd.Transaction = trans;

cmd.CommandType = cmdType;
cmd.CommandTime out = 240;

if (cmdParms != null)
{
foreach (SqlParameter parm in cmdParms)
cmd.Parameters. Add(parm);
}
return;
}

*************** *************** *************** ***********

"Matt" wrote:
I'm having an issue with returning a large amount of data into a dataset.
When the query returns thousands of lines of data (in Query Analyzer it can
take 2 minutes) I receive the following error:
Message: System.Web.Serv ices.Protocols. SoapException: Server was unable to
process request. ---> System.Data.Sql Client.SqlExcep tion: Timeout expired.
The timeout period elapsed prior to completion of the operation or the server
is not responding.

My assumption is that I need to raise the command timeout to correct this.
I cannot find a way while using SqlHelper.Execu teDataSet to include a change
to the command timeout. Here is an example of my webservice:
[WebMethod]
public System.Data.Dat aSet QuerySpecificTr ansaction(int transactionID)
{
SqlConnection conn = new SqlConnection() ;
DataSet ds = new DataSet();
SqlParameter[] parms = new SqlParameter[1];

try
{
conn.Connection String =
System.Configur ation.Configura tionSettings.Ap pSettings["ConnectionStri ng"];
parms[0] = new SqlParameter("@ transactionID", SqlDbType.Int);
parms[0].Value = transactionID;
ds = SqlHelper.Execu teDataset(conn, CommandType.Sto redProcedure,
"QuerySpecificT ransaction", parms);
}
catch(Exception exc)
{
throw exc;
}
finally
{
if (conn.State != ConnectionState .Closed)
{
conn.Close();
}
}
return ds;
}

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
17974
by: hb | last post by:
Hi, I got the "System.Data.SqlClient.SqlException: Timeout expired. " error on my web application while saving some data. Would you please tell me how to change the settings in SQL Server 2000 or IIS to increase the timeout?
2
4567
by: Chris Langston | last post by:
I have a Web Server running IIS 5 or 6 on Windows 2K and Windows 2003 Server that is experiencing strange shutdown problems. We are using ASP.NET v1.1 and our application is written in VB.NET Here's the scenario: 1. .NET Windows Client on a remote machine makes a web service call to update tables on a Web Server running SQL Server...
0
4076
by: Ersin Gençtürk | last post by:
we are getting : System.Web.HttpUnhandledException: Exception of type System.Web.HttpUnhandledException was thrown. ---> 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...
2
2379
by: Nils Magnus Englund | last post by:
Hi, I've made a HttpModule which deals with user authentication. On the first request in a users session, it fetches data from a SQL Server using the following code: using (SqlConnection connection = new SqlConnection(ConfigurationSettings.AppSettings)) {
3
13963
by: Nils Magnus Englund | last post by:
Hi, I've made a HttpModule which deals with user authentication. On the first request in a users session, it fetches data from a SQL Server using the following code: using (SqlConnection connection = new SqlConnection(ConfigurationSettings.AppSettings)) {
4
1868
by: Stephen Noronha | last post by:
Hi, I have an unusual error, "System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding......and so on " I have never seen such an error. Yes, i do agree that the SP takes anywhere b/w 2-5 min to return data and i have no "connection timeout...
4
13162
by: VB Programmer | last post by:
When I run my ASP.NET 2.0 web app on my dev machine it works perfect. When I precomile it to my web deployment project and then copy the debug files to my web server I get this problem when trying to login (obviously it's using ASPNETDB.mdf). Any ideas? Server Error in '/' Application....
1
45155
by: Ron | last post by:
Hi, I had a stored procedure on SQL 2000 server to run calculation with large amount of data. When I called this stored procedure via System.Data.SqlClient.SqlCommand on production, i got error as: (i tried to run the stored procedure on query analyzer, and it works well) Timeout expired. The timeout period elapsed prior to completion of...
1
5159
by: Scorpion657 | last post by:
Hey I really need help. I have a Website coded using ASP.NET and VB and for some reason, i'm getting the following error when I try to upload or access a large file which is stored in the database. It was working fine when I was runing the site on the localhost. I added the following line to the web.config file to increase the timeout: ...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7678
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6286
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5222
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.