Note that there are some explanatory texts on larger screens.

plurals
  1. POIncorrect syntax near the keyword 'WHERE' once added variable for total
    primarykey
    data
    text
    <p>I'm having this problem where once I've calculated to display (Quantity * Price) As Total FROM ShoppingCart, it managed to display the total for the total item user purchased but I couldn't update or delete at the column and when I update it straight away give me this error "Incorrect syntax near the keyword 'WHERE'" </p> <p>I'll Provide the code here:</p> <pre><code>&lt;asp:GridView ID="GridView2" runat="server" AllowPaging="True" AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource2" ForeColor="#333333" GridLines="None" AllowSorting="True"&gt; &lt;FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /&gt; &lt;RowStyle BackColor="#EFF3FB" /&gt; &lt;Columns&gt; &lt;asp:CommandField ShowDeleteButton="True" ShowEditButton="True" /&gt; &lt;asp:BoundField DataField="ProductID" HeaderText="ProductID" SortExpression="ProductID" /&gt; &lt;asp:BoundField DataField="UserName" HeaderText="UserName" SortExpression="UserName" /&gt; &lt;asp:BoundField DataField="InsertDate" HeaderText="InsertDate" SortExpression="InsertDate" /&gt; &lt;asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" /&gt; &lt;asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" /&gt; &lt;asp:BoundField DataField="OrderID" HeaderText="OrderID" SortExpression="OrderID" /&gt; &lt;asp:BoundField DataField="Total" HeaderText="Total" SortExpression="Total" /&gt; &lt;/Columns&gt; &lt;PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /&gt; &lt;SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /&gt; &lt;HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /&gt; &lt;EditRowStyle BackColor="#2461BF" /&gt; &lt;AlternatingRowStyle BackColor="White" /&gt; &lt;/asp:GridView&gt; &lt;asp:SqlDataSource ID="SqlDataSource2" runat="server" ConflictDetection="CompareAllValues" ConnectionString="&lt;%$ ConnectionStrings:ConnectionString %&gt;" DeleteCommand="DELETE FROM [ShoppingCart] WHERE [CartID] = @original_CartID AND [ProductID] = @original_ProductID AND [UserName] = @original_UserName AND [InsertDate] = @original_InsertDate AND [Quantity] = @original_Quantity AND [Price] = @original_Price AND [OrderID] = @original_OrderID AND [Total]= @original_Total" InsertCommand="INSERT INTO [ShoppingCart] ([ProductID], [UserName], [InsertDate], [Quantity], [Price], [OrderID], [Total]) VALUES (@ProductID, @UserName, @InsertDate, @Quantity, @Price, @OrderID, @Total)" OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [ProductID], [UserName], [InsertDate], [Quantity], [Price], [OrderID], (Quantity * Price) As Total FROM [ShoppingCart]" UpdateCommand="UPDATE [ShoppingCart] SET [ProductID] = @ProductID, [UserName] = @UserName, [InsertDate] = @InsertDate, [Quantity] = @Quantity, [Price] = @Price, [OrderID] = @OrderID, [Total]= @Total, WHERE [CartID] = @original_CartID AND [ProductID] = @original_ProductID AND [UserName] = @original_UserName AND [InsertDate] = @original_InsertDate AND [Quantity] = @original_Quantity AND [Price] = @original_Price AND [OrderID] = @original_OrderID AND [Total]= @Total"&gt; &lt;DeleteParameters&gt; &lt;asp:Parameter Name="original_CartID" Type="Int32" /&gt; &lt;asp:Parameter Name="original_ProductID" Type="Int32" /&gt; &lt;asp:Parameter Name="original_UserName" Type="String" /&gt; &lt;asp:Parameter Name="original_InsertDate" Type="DateTime" /&gt; &lt;asp:Parameter Name="original_Quantity" Type="Int32" /&gt; &lt;asp:Parameter Name="original_Price" Type="Decimal" /&gt; &lt;asp:Parameter Name="original_OrderID" Type="Int32" /&gt; &lt;asp:Parameter Name="original_Total" Type="Decimal" /&gt; &lt;/DeleteParameters&gt; &lt;InsertParameters&gt; &lt;asp:Parameter Name="ProductID" /&gt; &lt;asp:Parameter Name="UserName" /&gt; &lt;asp:Parameter Name="InsertDate" /&gt; &lt;asp:Parameter Name="Quantity" /&gt; &lt;asp:Parameter Name="Price" /&gt; &lt;asp:Parameter Name="OrderID" /&gt; &lt;asp:Parameter Name="Total" /&gt; &lt;/InsertParameters&gt; &lt;UpdateParameters&gt; &lt;asp:Parameter Name="ProductID" Type="Int32" /&gt; &lt;asp:Parameter Name="UserName" Type="String" /&gt; &lt;asp:Parameter Name="InsertDate" Type="DateTime" /&gt; &lt;asp:Parameter Name="Quantity" Type="Int32" /&gt; &lt;asp:Parameter Name="Price" Type="Decimal" /&gt; &lt;asp:Parameter Name="OrderID" Type="Int32" /&gt; &lt;asp:Parameter Name="Total" Type="Decimal" /&gt; &lt;asp:Parameter Name="original_CartID" Type="Int32" /&gt; &lt;asp:Parameter Name="original_ProductID" Type="Int32" /&gt; &lt;asp:Parameter Name="original_UserName" Type="String" /&gt; &lt;asp:Parameter Name="original_InsertDate" Type="DateTime" /&gt; &lt;asp:Parameter Name="original_Quantity" Type="Int32" /&gt; &lt;asp:Parameter Name="original_Price" Type="Decimal" /&gt; &lt;asp:Parameter Name="original_OrderID" Type="Int32" /&gt; &lt;asp:Parameter Name="original_Total" Type="Decimal" /&gt; &lt;/UpdateParameters&gt; &lt;/asp:SqlDataSource&gt; </code></pre> <p>Do guide me in this i dont know what they mean by the error.This is for the admin who can update or delete in the shopping cart</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload