tags:

views:

34

answers:

1

I have a Stored Procedure that returns three record sets. Here it is being called in Studio.

EXEC CampaignData '007CF7F8-AE8D-DE11-8BBA-0003FF4C13C9'

I can't cut and paste the record sets from Management Studio but trust me it shows three record sets, first one has one row with 2 values, the second has three rows and the third has 2 rows.

Here is my c# reading it

using (DAResult daResult = DA.SP.CampaignData(new Guid("007CF7F8-AE8D-DE11-8BBA-0003FF4C13C9")).Execute())
{
daResult.Read();
UserCount = daResult.ValueInt("UserCount");
ProspectCount = daResult.ValueInt("ProspectCount");

daResult.Next();
EmailTemplates = new DataTable();
EmailTemplates.Load(daResult.Reader);

daResult.Next();
SMSTemplates = new DataTable();
SMSTemplates.Load(daResult.Reader);
}

Next() just calls NextResult on the Reader. When I get to the last line the reader has no rows in it. Like the last record set returned no rows. Yet it does. All the rest of the values return fine.

Does anybody have any ideas why this might be?

+2  A: 

"EmailTemplates.Load(daResult.Reader);"
The Load method consumes the first result set from the loaded IDataReader, and after successful completion, sets the reader's position to the next result set, if any.
So you should only remove line of code:"daResult.Next();"

sesame
Well I never. I never new that and now that I look in all the other places I'ved used it the DataTable load is the last thing done.Now works a treat. Wish I'd asked 2 hours ago.
scott barbary