i loaded records from my database and fill my text boxes and i'm trying to update with the record in the text but not work.please help me
What I have tried:
protected void Update_Click(object sender, EventArgs e)
{
ccObject = new ConnectionClass();
if (!IsPostBack)
{
try
{
ccObject.Query(" uspUpdateProductInventory");
ccObject.cmd.Parameters.AddWithValue("@QuantityToAdd", TbxQtytoAdd.Text);
ccObject.cmd.Parameters.AddWithValue("@ProductCode", TbxProductCode.Text);
ccObject.ExcuteQuery();
string SuccessMessage = "INVENTORY UPDATE SUCCESSFUL";
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + SuccessMessage + "');", true);
}
catch (Exception ex)
{
throw ex;
}
finally
{
ccObject.CloseConnection();
}
}
}
-------------------- usp for update----------------------------------
ALTER PROCEDURE [dbo].[uspUpdateProductInventory]
-- Add the parameters for the stored procedure here
@QuantityToAdd int,
@ProductCode varchar(50)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
UPDATE Product.Inventory set QuantityAtStore = QuantityAtStore + @QuantityToAdd WHERE ProductCode=@ProductCode
END
the database table has
|id|ProductCode|QuantityAtStore|
| | | |
__--------------------------------------------------------------------------------
<div class="form-group">
<label for="productcode">Product Code</label>
<asp:TextBox ID="TbxProductCode" CssClass="form-control" runat="server" OnTextChanged="TbxProductCode_TextChanged" AutoPostBack="True"></asp:TextBox>
<asp:RequiredFieldValidator ID="RfvProductCode" runat="server" ErrorMessage="Enter Product Code" ForeColor="Red" ControlToValidate="TbxProductCode" Display="Dynamic" ></asp:RequiredFieldValidator>
</div>
<div class="form-group">
<label for="ProductName">Product Name</label>
<asp:TextBox ID="TbxProductName" CssClass="form-control" ReadOnly="true" runat="server"></asp:TextBox>
</div>
<div class="form-group">
<label for="Quantity in store">Quantity in Store</label>
<asp:TextBox ID="TbxQtyinStore" CssClass="form-control" ReadOnly="true" runat="server"></asp:TextBox>
</div>
<div class="form-group">
<label for="quantity to add">Quantity to Add</label>
<asp:TextBox ID="TbxQtytoAdd" CssClass="form-control" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RfvQuantityToAdd" runat="server" ErrorMessage="Enter Quantity To Add" ForeColor="Red" ControlToValidate="TbxQtytoAdd" Display="Dynamic" ></asp:RequiredFieldValidator>
<asp:CompareValidator ID="CvQuantityToAdd" runat="server" ErrorMessage="invalid Quantity" ControlToValidate="TbxQtytoAdd" Operator="DataTypeCheck" Type="Integer" Display="Dynamic" ForeColor="Red" ></asp:CompareValidator>
</div>