Jump to content

Debuggin UpdateCommand code segment

- - - - -

  • Please log in to reply
No replies to this topic

#1
Blue Indian

Blue Indian

    Learning Programmer

  • Members
  • PipPipPip
  • 67 posts
Please take a look at the following code segment. My problem is coming from the UPDATE part of this segment, specifically where I am trying to use @Field, @NewValue, and @SKU. When I debug this application the update command is not getting transformed as I expected with the associated values of the controls on my page. Instead, I am just getting this literal sql statement: UPDATE coffee SET @Field=@NewValue WHERE COFFEE_SKU=@SKU

Note: The update portion of the following code segment was hard coded by myself and not generated code from VS. I couldn't figure out how to get VS to generate the update so I looked up a solution online.

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:harrison8786ConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:harrison8786ConnectionString.ProviderName %>" 
        SelectCommand="SELECT COFFEE_SKU, COFFEE_NAME, COFFEE_DETAILS, coffee_price FROM coffee"
        UpdateCommand="UPDATE coffee SET @Field=@NewValue WHERE COFFEE_SKU=@SKU">
        <UpdateParameters>
              <asp:ControlParameter Name="Field" ControlId="ddlField" PropertyName="SelectedValue"/>
              <asp:ControlParameter Name="NewValue" ControlId="txtNewValue" PropertyName="Text"/>
              <asp:ControlParameter Name="SKU" ControlId="ddlCoffeeNames" PropertyName="SelectedValue"/>
          </UpdateParameters>
    </asp:SqlDataSource>





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users