views:

160

answers:

2

I constructed a stored procedure that does the equivalent of FOR XML AUTO in SQL Server 2008. Now that I'm testing it, it gives me a really unhelpful error message. What does this error mean?

Msg 10329, Level 16, State 49, Procedure ForXML, Line 0 .NET Framework execution was aborted.

System.Threading.ThreadAbortException: Thread was being aborted.

System.Threading.ThreadAbortException:

  at System.Runtime.InteropServices.Marshal.PtrToStringUni(IntPtr ptr, Int32 len)
  at System.Data.SqlServer.Internal.CXVariantBase.WSTRToString()
  at System.Data.SqlServer.Internal.SqlWSTRLimitedBuffer.GetString(SmiEventSink sink)
  at System.Data.SqlServer.Internal.RowData.GetString(SmiEventSink sink, Int32 i)
  at Microsoft.SqlServer.Server.ValueUtilsSmi.GetValue(SmiEventSink_Default sink, ITypedGettersV3 getters, Int32 ordinal, SmiMetaData metaData, SmiContext context)
  at Microsoft.SqlServer.Server.ValueUtilsSmi.GetValue200(SmiEventSink_Default sink, SmiTypedGetterSetter getters, Int32 ordinal, SmiMetaData metaData, SmiContext context)
  at System.Data.SqlClient.SqlDataReaderSmi.GetValue(Int32 ordinal)
  at System.Data.SqlClient.SqlDataReaderSmi.GetValues(Object[] values)
  at System.Data.ProviderBase.DataReaderContainer.CommonLanguageSubsetDataReader.GetValues(Object[] values)
  at System.Data.ProviderBase.SchemaMapping.LoadDataRow()
  at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)
  at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
  at System.Data.Common.DataAdapter.Fill(DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
  at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
  at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
  at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
  at ForXML.GetXML...
+2  A: 

I'm pretty sure it means you did it wrong...

On another note: It looks like you are filling a datatable. during the call it's trying to convert something into a string value.. and failing.

You're going to have to look at the columns that are coming back to see if there is one that can't convert to a string representation. Maybe a binary or null value, or something like that.

Chris Lively
"I'm pretty sure it means you did it wrong..." Wow. I would never have figured that one out. I think that is probably the most awesome answer that I've *ever* received on stackoverflow. I would say something even more sarcastic and mean here, but that wouldn't be productive. If you have an answer (as you did, later in your post) then you should add it without being a jerk about it.
Sean Ochoa
Wow. It was meant as a tongue-in-cheek response to the general question of "here's an error, but I haven't provided any code nor data to go along with it to give anyone a clue as to what might have happened" Would a little smiley face have made a difference? lighten up dude.
Chris Lively
@Sean Ochoa: [Lighten Up...](http://www.youtube.com/watch?v=fiH9yXKSMVM#t=5m2s)
Randolpho
+2  A: 

Typically Thread Abort exceptions occurring during ADO.NET DataSet/Table/Adapter filling happen because the query ran longer than the timeout of whatever means was used to retrieve the data.

In your case it looks like you're using a direct SQL Server connection, so I'd say try setting the CommandTimeout property for your SQL command to a sufficiently large value to accommodate your query. That, or fine-tune the query or even the application architecture for better performance.

Randolpho
I missed the ThreadAbortException the first time I read the stack dump. Your analysis looks to be right.
Chris Lively