【问题标题】:GridView and Stored Procedure?GridView 和存储过程?
【发布时间】:2016-02-20 04:58:30
【问题描述】:

我想在 Visual Studio 中使用 GridView。我浏览了他们的教程,我已经设置好了。但是我看不到如何使用我的存储过程。

它让我明白了:

 <asp:SqlDataSource ID="SqlDataSourceViewRegistrants" runat="server" 
        ConnectionString="<%$ ConnectionStrings:Events2 %>" 
        SelectCommand="SELECT * FROM [Registrant]"></asp:SqlDataSource>

我想用存储过程替换 SelectCommand,如下所示:

sqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
sqlCmd.CommandText = "spGetAllRegistrants";

我不知道把spGetAllRegistrants的这个信息放在哪里。

【问题讨论】:

    标签: asp.net stored-procedures gridview


    【解决方案1】:

    您需要将SelectCommandType 更改为StoredProcedure

    <asp:SqlDataSource ID="SqlDataSourceViewRegistrants" runat="server" 
    ConnectionString="<%$ ConnectionStrings:Events2 %>" 
    SelectCommand="spGetAllRegistrants"
    SelectCommandType="StoredProcedure"></asp:SqlDataSource>
    

    【讨论】:

      猜你喜欢
      • 2011-03-04
      • 2013-12-23
      • 2016-02-20
      • 1970-01-01
      • 2016-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-17
      相关资源
      最近更新 更多