解决方案 »

  1.   

    你没明白我的意思,我是说采用异步页面,当用户请求的时候先用一个IIS线程,然后在读取数据库的时候,已经将该线程释放,在读取数据完毕的时候,再从线程池中取一个线程返回结果。
      

  2.   

    若你读取数据时间太长 可以考虑用缓存 
    你用异步方式去读取数据其实iis还是会一直占用一个线程的 并不会达到你的目的
      

  3.   

    哦,那知晓了。就是IIS在读数据库的时候,也是需要线程池的线程是吧?不是连接池的线程吗?接收http请求的线程池跟数据库连接池是同一个池吗?盼复。谢谢。
      

  4.   

    异步读取数据库中的数据也可局部更新示例
    //异步更新设置
     <asp:ScriptManager ID="ScriptManager1"//添加AJAX
                                   runat="server" />
     <asp:UpdatePanel ID="OrdersPanel"//局部异步刷新设置
                                 UpdateMode="Conditional"
                                 runat="server">
                    <ContentTemplate>
    //当局部刷新时不影响全局数据加快数据显示时速
      <asp:GridView ID="GridView1" 
                                      AllowPaging="True"
                                      Caption="商品类别主表数据"
                                      DataKeyNames="GoodsTypeID"
                                      OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
                                      runat="server" Width="608px" BackColor="LightGoldenrodYellow" 
                            BorderColor="Tan" BorderWidth="1px" CellPadding="2" ForeColor="Black" 
                            GridLines="None" SelectedIndex="0" 
                            onpageindexchanging="GridView1_PageIndexChanging" style="font-size: small" 
                            EmptyDataText="没有相关数据可以显示!" >
                        <Columns>
                        <asp:CommandField ShowSelectButton="True"></asp:CommandField>
                        </Columns>
                            <FooterStyle BackColor="Tan" />
                            <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
                            <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
                            <HeaderStyle BackColor="Tan" Font-Bold="True" />
                            <AlternatingRowStyle BackColor="PaleGoldenrod" />
                        </asp:GridView>
                    </ContentTemplate>
     </asp:UpdatePanel>
    //添加另一个异步刷新显示数据库数据
     <asp:UpdatePanel ID="OrderDetailsPanel"
                                 UpdateMode="Conditional"
                                 runat="server">
                    <ContentTemplate>
                        <asp:GridView ID="GridView2" runat="server" BackColor="White" BorderColor="#E7E7FF"
                            BorderStyle="None" BorderWidth="1px" Caption="商品明细数据" CellPadding="3" DataKeyNames="GoodsTypeID,GoodsID"
                            GridLines="Horizontal" Width="657px" AllowSorting="True" 
                            AutoGenerateColumns="False" onsorting="GridView2_Sorting" 
                            style="font-size: small">
                            <Columns>
                                <asp:BoundField DataField="GoodsID" HeaderText="商品编号" SortExpression="GoodsID" />
                                <asp:BoundField DataField="GoodsTypeID" HeaderText="类别编号"  SortExpression="GoodsTypeID"/>
                                <asp:BoundField DataField="GoodsName" HeaderText="商品名称" SortExpression="GoodsName" />
                                <asp:BoundField DataField="GoodsIntroduce" HeaderText="商品简介" SortExpression="GoodsIntroduce" />
                                <asp:BoundField DataField="GoodsPrice" HeaderText="商品价格"  SortExpression="GoodsPrice"/>
                                                                                                             </Columns>
                            <AlternatingRowStyle BackColor="#F7F7F7" />
                            <EmptyDataTemplate>
                                                       </EmptyDataTemplate>
                            <EmptyDataRowStyle BackColor="#404040" ForeColor="Red" />
                        </asp:GridView>//CodeGo.net/
                        <br />
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="GridView1" EventName="SelectedIndexChanged" />
                      <asp:AsyncPostBackTrigger ControlID="GridView1" EventName="PageIndexChanged" />
                       
                         </Triggers>
                </asp:UpdatePanel>
    //绑定表中数据显示
     public void getOrders()
        {
            string strSql = "select * from tb_GoodsType";//查询商品类别表
            this.GridView1.DataSource = GetDataBySql(strSql);//设定其绑定的数据源
            this.GridView1.DataKeyNames = new string[] { "GoodsTypeID" };
            this.GridView1.DataBind();
        }