locked
sum or count in sql data source RRS feed

  • Question

  • User-646447061 posted

    i want to sum or count  field id, but i got message "

    A field or property with the name 'id' was not found on the selected data source.

    "     

            <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                        SelectCommand="SELECT sum([id]) FROM [penjualan] GROUP BY [name]">
                    </asp:SqlDataSource>

    thanks before

    Monday, February 29, 2016 12:31 AM

Answers

  • User-646447061 posted

    SOLVED

                    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                        
                        SelectCommand="SELECT [id_pembelian], SUM([harga]) as x FROM [penjualan] GROUP BY [id_pembelian]">
                    </asp:SqlDataSource>

    in bounfield datafield="x"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 29, 2016 1:02 AM