我有一个客户购物车,它显示客户想要购买的购物车。我想在客户购物车上删除一行。
购物车显示基于cust_id
.
我正在使用这个查询来显示。
SELECT
tableCustomerCart.cart_quantity, tableFoodDetail.food_title,
tableFoodDetail.food_price, tableFoodDetail.food_image,
tableCustomerCart.cart_price
FROM
tableFoodDetail
INNER JOIN
tableCustomerCart ON tableFoodDetail.food_id = tableCustomerCart.cart_id
WHERE
tableCustomerCart.cust_id = @cust_id
我的问题是删除特定 id () 的特定行的查询是什么cust_id
?
这是我的 sql 数据源。
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" DeleteCommand="DELETE FROM tableCustomerCart WHERE cust_id=@cust_id" SelectCommand="SELECT tableCustomerCart.cart_quantity, tableFoodDetail.food_title, tableFoodDetail.food_price, tableFoodDetail.food_image, tableCustomerCart.cart_price FROM tableFoodDetail INNER JOIN tableCustomerCart ON tableFoodDetail.food_id = tableCustomerCart.cart_id WHERE tableCustomerCart.cust_id = @cust_id">
<DeleteParameters>
<asp:Parameter Name="cust_id"/>
</DeleteParameters>
<SelectParameters>
<asp:SessionParameter Name="cust_id" SessionField="cust_id" />
</SelectParameters>
</asp:SqlDataSource>
我的网格视图
<asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:CommandField ShowDeleteButton="True" />
<asp:BoundField DataField="cart_quantity" HeaderText="cart_quantity" SortExpression="cart_quantity" />
<asp:BoundField DataField="food_title" HeaderText="food_title" SortExpression="food_title" />
<asp:BoundField DataField="food_price" HeaderText="food_price" SortExpression="food_price" />
<asp:BoundField DataField="food_image" HeaderText="food_image" SortExpression="food_image" />
<asp:BoundField DataField="cart_price" HeaderText="cart_price" SortExpression="cart_price" />
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
“删除”选项卡。
DELETE FROM tableCustomerCart WHERE cust_id=@cust_id