Hi guys,
I'm trying to update a table through stored procedure. I am having a page from which on button click a popup window appears. i'm sending a ID from the main page to the popup window using querystring, where the details from the table by ID is displayed in textbox. Here we can change the values and on button click the values should be updated to the table by the ID, where the ID = the Querystring value.
The Code on the button_click is like this:-
SqlConnection con = new SqlConnection(Application["con_pth"].ToString());
SqlCommand update_item = new SqlCommand("update_item_by_id", con);
update_item.CommandType = CommandType.StoredProcedure;
update_item.Parameters.Add("@item_id", SqlDbType.Int).Value = Request.QueryString["item_id"];
update_item.Parameters.Add("@cost_price", SqlDbType.Float).Value = TextBox1.Text;
update_item.Parameters.Add("@sell_price", SqlDbType.Float).Value = TextBox2.Text;
update_item.Parameters.Add("@dealer_id", SqlDbType.VarChar).Value = ComboBox1.SelectedValue;
con.Open();
update_item.ExecuteNonQuery();
con.Close();
The Stored Procedure is like this:-
ALTER PROCEDURE dbo.update_item_by_id
(
@item_id int,
@cost_price float,
@sell_price float,
@dealer_id int
)
AS
UPDATE stock
SET cost_price =@cost_price, sell_price =@sell_price, dealer_id =@dealer_id
WHERE (item_id = @item_id)
RETURN
But the problem is whn i click on the button the table is not getting updated with the new values. There is no error or exception thrown, but the update is also not done. What am i missing??? Please help..