C# – Stored Procedure Returns Multiple Recordsets

c++multiple-resultsetsweb-applications

I am pretty new to c#.
I have a page that requires multiple recordsets, and a single sproc that returns them. I am using a repeater control for the main recordset. How do I get to the next returned recordset?


OK so the datasource is in the aspx page. I would have move it to the code behind page to use NextResult right? Here is my code now. How do I move the datasource to the codebehind, implement a datareader so I can use nextresult?

<asp:SqlDataSource ID="AssetMgtSearch" runat="server" 
                ConnectionString="<%$ ConnectionStrings:OperationConnectionString %>" 
                SelectCommand="spAssetMgtItemList" SelectCommandType="StoredProcedure">
            </asp:SqlDataSource>
            <div class="contentListFullHeight">
                <table cellspacing="0" cellpadding="0" border="0" class="contentList">
                    <tr>
                        <th>ShipmentID/</td>
                        <th>MaterialID/</td>
                        <th>ItemID/</td>
                    </tr>
                    <asp:Repeater ID="Repeater1" runat="server" DataSourceID="AssetMgtSearch">
                        <ItemTemplate> 
                            <tr>
                                <td colspan="3" style="border-top:solid thin blue">&nbsp;</td>
                            </tr>
                            <tr>
                                <td><%#Container.DataItem(0)%></td>
                                <td><%#Container.DataItem(1)%></td>
                                <td><%#Container.DataItem(2)%></td>
                            </tr>
                        </ItemTemplate>                           
                    </asp:Repeater>
                </table>

Best Solution

Call the NextResult() method on your reader to move to the next result.

No, you can't do this using SqlDataSource, you need to use codebehind or break up the procedure into separate queries.