[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3084
  • Last Modified:

Thread was being aborted exception with Web Service/SQL Server

Hi

We have a C# web service which calls SPs (via the ADO.NET SqlCommand and SqlDataAdapter objects) to read data from a SQL Sever 2000 database.  We get the following exception intermittently

Thread was being aborted.
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)    
at System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)    
at System.Data.Common.DbDataAdapter.Fill(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)    
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable, IDbCommand command, CommandBehavior behavior)     at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)  

Our connection and command timeouts are set to 30 seconds.

If anyone can help, I'd greatly appreciate an explanation or (even better) a workaround

TIA
Wile_E
0
wile_e_coyote
Asked:
wile_e_coyote
  • 6
  • 3
  • 2
1 Solution
 
frodomanCommented:
Check your maximum concurrent connections on SQL Server.  Possibly this is intermittent because you're exceeding the max connections specified - your thread will wait for a free connection and then timeout if one isn't freed up.

0
 
mondayblueboyCommented:
Do you have exception handler in the code? If yes, I suspect the error comes from a line in the try block. Post code might be helpful.

0
 
wile_e_coyoteAuthor Commented:
Frodoman - I'm looking into your suggestion.

MondayBlueBoy - Here is (more or less) the code.   But take a look at the stack trace from above.  The error is occuring in the Fill method of the dataadapter.

DataSet ds = new DataSet();
SqlConnection cn = new SqlConnection (...);
SqlDataAdapter da = new SqlDataAdapter ();
da.SelectCommand = mySelectCmd;     //mySelectCmd is on the web service designer and is an SP call

try
{
  da.Fill (ds);
}
catch (Exception e)
...



0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
mondayblueboyCommented:
Just one more q.
Is that all code in the try block?
0
 
wile_e_coyoteAuthor Commented:
Yes
0
 
wile_e_coyoteAuthor Commented:
Frodoman - our DBA says we are set up to allow unlimited connections
0
 
frodomanCommented:
Possible user interaction during the time your fill is being executed?  Normally the "Thread being aborted" message occurs on a webform during a response.redirect / response.end type of execution (both of which always throw a ThreadAbortException).

I may be completely off base here, but if it's an intermittent problem is it possible that a user is clicking something during the fill that is causing the page to try to reload / change before the dataset is full?
0
 
wile_e_coyoteAuthor Commented:
Naw - the error is reported by the web service (on the SqlDataAdapter.Fill call), not the UI (which is a windows forms app).
0
 
frodomanCommented:
Sorry wile_e - Nothing else I can think of, but good luck solving it!
0
 
wile_e_coyoteAuthor Commented:
Its worth an additional 250 points for me to make some progress on this.   Any takers?
0
 
wile_e_coyoteAuthor Commented:
Turns out that the httpRuntime executionTimeout setting in the machine.config file on the web server was causing IIS to kill the thread after 90 seconds.   Increasing this setting resolved the problem

I'm going to request that this question be closed.
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

  • 6
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now