开发者

SqlDataReader doesn't have third record set

开发者 https://www.devze.com 2022-12-14 20:21 出处:网络
I have a Stored Procedure that returns three record sets. Here it is being called in Studio. EXEC CampaignData \'007CF7F8-AE8D-DE11-8BBA-0003FF4C13C开发者_JS百科9\'

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

EXEC CampaignData '007CF7F8-AE8D-DE11-8BBA-0003FF4C13C开发者_JS百科9'  

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?


"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();"

0

精彩评论

暂无评论...
验证码 换一张
取 消