存储过程返回多个记录集

Pra*_*gus 1 c# web-applications multiple-resultsets

我对c#很新.我有一个需要多个记录集的页面,以及一个返回它们的sproc.我正在使用主记录集的转发器控件.如何进入下一个返回的记录集?


好的,所以数据源在aspx页面中.我会把它移到页面后面的代码中使用NextResult吗?这是我现在的代码.如何将数据源移动到代码隐藏,实现datareader以便我可以使用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>
Run Code Online (Sandbox Code Playgroud)

Wya*_*ett 9

在阅读器上调用NextResult()方法以转到下一个结果.

不,您不能使用SqlDataSource执行此操作,您需要使用代码隐藏或将过程分解为单独的查询.